July 17, 2014
May 6, 2014
I wrote this jQuery validation for a site and it all worked in my test page but for some reason it stopped working in the real page. Since the real page is a currently live, I started creating and testing the validation on the dummy page first. After some debugging for finding the issue, I realised that the jQuery is not running within the actual page since the controls and html elements are within the Update Panel.
April 29, 2014
Data attributes are a cool way to store extra data for html elements. Previously, when we needed to store additional data for an html element we would store it hidden elements whereas now with data attributes, we can store it within the html element itself as shown below.
Since data attributes are standard html attributes, we can use it within asp.net as well. Here's an example on how we can load country / capital data within a ListView control, store the capital information as data attribute and then display the capital when the user hovers over the country using jQuery.
April 22, 2014
The Handler basically gets the files uploaded and the saves it to a specified folder. In this instance, I am saving it to the UserFiles folder within the application. Make sure you have already created the folder with the correct permissions (read / write attributes). Here's the source code for the handler.
January 7, 2014
For this example, I will start with the web service. It's going to be asmx service that simply adds and subtracts numbers that it retrieves from the front end. Here's the code for the web service.
On the front end, I have couple of text fields, 1 option field to select to add or to subtract, a button that will trigger the script when clicked and a span element that will display the data. Here's the code for the html front end.
To start with I am calling jquery source file. Next, in the button click handler, I am forming the service url based on the selection. The important bit is this line
Note that a and b are parameter names in the service and I am sending the value of the text boxes. Finally, on success, I am populating the data in the span element. In case, error occurs, for example, if we type in "abc" in the text box or the web service is down, then the error function is fired and the text "Error!!!" is displayed within the span element.
Another thing to note is that the return value in json has .d at the end. This is within the success function as below.
The .d is a wrapper that ensures the payload is a json object.