AJAX

15 posts

AJAX request timeout error

The default value of AJAX postback is 90 seconds, so if you have a long asynchronous postback, you will get an error as this: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out. The fix is to change the default timeout value to a larger value in your ScriptManger’s AsyncPostBackTimeout property (10 minutes as below): <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="600"> </asp:ScriptManager>

Display confirmation from code behind before continuing a process in ASP.NET (part one)

I noticed that many developers asked this question or similar: After a user clicks a button on a page, my application performs some check, then prompts user for confirmation, then based on user’s response, my application will either continue the process or cancel the process. How can I accomplish this? I wrote an article on Experts-Exchange.com regarding this question and here is the link to it: Display confirmation from code behind before continuing a process […]

How to build a multiple select DropDownList in ASP.NET

In this article, I will show you how to use AJAX PopupControlExtender to build a multiple select DropDownList as this: Firstly, we need an image captured from a standard drop down list as this:   I will use this image as the drop down list instead of the built-in ASP:DropDownList control, the reason is that when a drop down list is clicked, its own selections will be displayed and will overlap with the check box […]

Scroll to the top of an AJAX page upon UpdatePanel postback

By default, when an UpdatePanel is refreshed upon postbacks, the navigation position of the page will not change because the postback is only a partial postback. It is a nice behavior in most cases, but in some cases, it can be very annoying. For instance, if you have a Wizard control defined in an UpdatePanel for user data entry, and if the form is very long, then you will need to scroll to the bottom […]

Using AJAX ModalPopup with GridView control

This actually applies to other data controls such as Repeater and DataList, but here I will just focus on GridView control. On ASP.NET web site, there is a tutorial titled “using ModalPopup with a Repeater Control”. To make the ModalPopup work, the tutorial says that the ModalPopupExtender must be put within the <ItemTemplate> section of the Repeater control, but the popup panel is outside the Repeater control. The reason is that if the ModalPopupExtender control […]

Use FCKEditor to update record in ASP.NET

I wrote two posts on the integration and customization of FCKEditor in ASP.NET web application, today I will show how to use FCKEditor to update record. This demo consists of a GridView with an Edit button for each row which upon clicked will load a DetailsView, and the DetailsView has a field called Note where the FCKEditor is used to update it. 1. GridView layout: <asp:GridView ID=”gvCustomerList” runat=”server” AutoGenerateColumns=”False” CssClass=”grid” Width=”100%” CellPadding=”6″ DataKeyNames=”CustomerID”> <Columns> <asp:TemplateField […]

Parent/Child Window Design Approaches

Popup window can be very helpful for editing records. For example, you have a GridView of your customers, when you click on a row or an “edit” button/icon, a new window pops up for you to edit the selected customer. After the editing is done and the record is saved, the popup window is closed and the parent window is reloaded to reflect the updated information. This is a very common scenario for using parent/child […]

System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)

I got this error when I was working on a small AJAX demo project the other day. In this project I only have two TextBox controls and two AJAX CalendarExtender controls: one text box is for a begin date entry controlled by one CalendarExtender, and the other text box is for an end date entry controlled by the other CalendarExtender. Quite simple, right? However, the AJAX CalendarExtender does not have the ability to force user […]

AJAX UpdatePanel Causing Full Postback

When you use AJAX’s UpdatePanel, you may find that the controls inside of the UpdatePanel generate full postback instead of partial postback, if it occurs to you, then you may need to check your web.config file to see if there is a line like this: <xhtmlConformance mode=”Legacy” /> If yes, then that is the bad guy that causes all kinds of problems in AJAX including the issue mentioned above. Removing the line from web.config  will […]

File download with Response stream not working in UpdatePanel

It is very common to use the Response stream to manage file download process. For example, the following code snippet shows how to use the Response stream to download any file: The above code will work fine in most cases, however, if the Download button is in a UpdatePanel, then it will throw an AJAX error like this: The error message tells the cause the error: you cannot use Response.Write in the UpdatePanel, so how […]