Browse by Tags
All Tags »
DEV »
Tips & Tricks (
RSS)
Quick Tip – Including Empty Directory While Deploying a Web Application During this week I had to deploy an ASP.NET MVC 3 web application to a host environment using web deploy. The problem I faced was the deployment of an empty directory which is being used by the application. By design, when using web deploy tool in Visual Studio it skips empty directories when packaging a web application. So How can you deploy this empty directory and overcome this problem? The solution is to put an empty stub...
Quick Tip – Disable/Enable Button by Textbox Client Event using jQuery I find myself often with a need to disable/enable a button according to client events that occur on web pages. Today I helped to implement this behavior again so I thought it will be nice to share the code I used. In this example I’m disabling/enabling a button according to whether a textbox holds some text. I’m using jQuery to make the code simple. Pay attention that this solution can be implemented for other events also. The...
Discover which Control Raised a PostBack Yesterday I needed a solution for an annoying problem. I have some buttons on a ASP.NET web form and I need to know which button raised the postback not in the event itself but in the page load event. This post will show a way to solve this conundrum. Discover which Control Raised a PostBack When we use ASP.NET and we have ASP buttons on the page if we want to do something before their postback event happen we need to discover whether they raised a postback...
CompiledQuery in Entity Framework There are times when we want to make optimizations on some piece of code. If we want to reduce the cost of executing a query in Entity Framework we can use a CompiledQuery to the rescue. Yesterday I used added a compiled query to a code base which was executing multiple times. This reduced the execution time of the repeating queries. In the post I’ll explain what are CompiledQueries and how to use them. CompiledQuery CompiledQueries are a delegate which store a compiled...
The Regulator Yesterday, I reviewed a regular expression that was written by one of the developers and I needed to improve it since it wasn’t performing the appropriate thing. Since I know The Regulator tool, I opened it and in 5 minutes I came up with this regular expression which validate Israeli phone/cellular numbers: ^0(5[012345678]|6[47]|[23489]){1}(\-)?[^0\D]{1}\d{6}$ With The Regulator I created and checked the expression and then implemented it in the application. What is The Regulator?...
Applying Strategy Pattern Instead of Using Switch Statements Once in a while I’m stumbling on switch statements during a Code Review session. Whenever this is happening my first reaction is to understand why did the developer use it. Since using switch statement sometime implies spaghetti code and also can get very crowded (in case statements of course) in this post I’m going to show an alternative method that I prefer to use. Alternative Method for Switch Statements Whenever you start to use a switch...
Back to Basics – How to Invoke Web Methods from a Remote Machine I’ve been asked today how to enable invocation of WebMethods of an asmx web service from a remote machine for testing. The post holds the answer. How to Invoke Web Methods from a Remote Machine? Sometimes we want to test our asmx web service not from localhost but from a remote machine . Trying to open the test form of the web service from a remote machine will show the following message: “ The test form is only available for requests...
Quick Tip – Adding Business Validation Messages to ValidationSummary Two days ago I was asked how to insert business validation messages into a ValidationSummary control. The post is the answer I gave to the person who asked me. The Problem We have a web form that is doing input validation and output the errors inside a ValidationSummary control. Since ValidationSummary shows a summary of all validation errors from ASP.NET validators how can we add business validations which are part of the business...
Quick Tip – How to Enable Local Cache in Velocity (Microsoft Distributed Cache) Client Since I got this question twice this week, I’m writing this post. One of Velocity (Microsoft Distributed Cache) features is called local cache . In this post I’ll show how to enable that feature. Velocity Client Local Cache Local cache is a Velocity feature that can help speed up access on Velocity clients. When enabled, a de-serialized copy of the object is saved in the client memory. Before retrieving cached...
Creating AutoCompleteExtender Trigger Button Yesterday I’ve been consulting at a client. During the day, I got a question regarding ASP.NET AJAX Control Toolkit ’s AutoCompleteExtender . The question was how to create a trigger button to the AutoCompleteExtender in order to go to the server and fetch the results. This post will describe how to do that. Creating an Autocomplete Web Service The first thing to do when you want to use the AutoCompleteExtender is to create the web service that you’ll...