In this post, I would like to discuss how to integrate Ajax with custom application pages in SharePoint. This article assumes that you are using .NET Framework 3.5. You need not install anything because .NET Framework 3.5 supports Ajax and it includes all Ajax related stuff like script manager, update panel, etc. Paste below line in content place holder with ID “Main”.
<asp:ScriptManager ID=”ScriptManager1″ runat=”server” >
This will add script manager to the application page and manages ASP.NET Ajax script librar ies and script files, partial-page rendering, and client proxy class generation for Web and application services. Then add the following block next to end of script manager.
<asp:UpdateProgress runat=”server” id=”PageUpdateProgress”>
UpdateProgress control starts working when asynchronous operations are in progress and provides visual feedback in the browser when the contents of one or more UpdatePanel controls are updated. I used a animated image for showing on screen while asynchronous operations are in progress. Then add below lines
<asp:UpdatePanel ID=”updatePanel1″ runat=”server” UpdateMode=”Conditional”>
//Put your controls here
UpdatePanel enables sections of a page to be partially rendered without a postback. With this you are almost done Ajaxfying your application page. Only thing left on this is, you need to register async post back control in code behind file of your aspx page.You can do this by adding the following line in page load event of the aspx page.
In the above line btnCreate is the control ID I used for actual operations has to be done in post back.With this you are done.Few things you need to take care are:Some controls may not support post back scenarios during partial page rendering. For example, File Upload control.If you are using file upload control in your aspx page, the file must be uploaded by using a control that is a post back trigger object for the panel. Update Panels are used to update selected regions of a page instead of updating the whole path with a post back. Useful links on this:
Using the AJAX Update Panel in SharePoint
Script Manager Class
Using the FileUpload Control with the UpdatePanel Control