Prevent multiple AJAX button clicks or postbacks

When a button click uses an AJAX postback, no page refresh happens. Due to poor network connectivity, the user might experience latency in getting the response. This might lead to the user making multiple button clicks. This is undesirable. If an AJAX Postback event is being processed on the page, we want to ensure all button clicks are disabled. Sys.WebForms.PageRequestManager is the[…]

Read more

Handling events of nested controls within GridView

A GridView contains two dropdownlists. The first dropdownlist is a simple Yes / No. On selecting Yes, the second dropdownlist should be enabled. How do I implement this? The GridView contains three columns: First Name, Alien DropDownList (Yes/No), Country DropDownList. The DropDownList is present in the TemplateColumn. Depending on the selection in the first DropDownList, the second DropDownList is enabled[…]

Read more

Nested GridViews Bound to ObjectDataSource

How can I display Country and City information in a nested fashion like: India Delhi Bangalore Chennai USA New York Chicago UK London This can be done in three steps: Create a object that will fetch data from database and structure it as collection of countries and collection of cities for each country.

Create a nested Gridview with outer[…]

Read more

WebMethod Example

I want a label box to be refreshed every one second with a random number generated at the server This is a classic example of WebMethods. WebMethods are written on the server side in the page class. WebMethods are static. Here is a simple implementation of a webmethod:

To be able to call this WebMethod from Javascript, the asp:ScriptManager[…]

Read more

Cropping Images to similar size

I want to show images of different sizes in a ListView. The image is displayed in a standard size. However, I do not want the images to be skewed or expanded while displaying.How can I do this? The most common approach is to use Image.GetThumbnailImage(). This will work if all images have the same width / height ratio. But if[…]

Read more

Popup Calendar Control

I want a simple Calendar control. The Calendar control should function like a FileUpload control. It should have a textbox and a button. On click on a button, the calendar control should open. On selecting a date in the calendar control, the popup window should close, and the textbox should be filled with the date. I want this Popup Calendar[…]

Read more

Handling OnDblClick Event of GridViewRow

I have a GridView that displays a list of names. On double-clicking a name, the name needs to be set in a textbox. This needs to happen w/o any postback The RowCreated event of GridView should add a javascript event handler for the OnDblClick event as follows: ASPX Page:

RowCreated Event Handler:

The Javascript for the SetSearch() is[…]

Read more