Integrating ASP.NET Ajax WebPart with SharePoint 3.0
page 3 of 8
by Abdulla Hussein AbdelHaq
Average Rating: 
Views (Total / Last 10 Days): 47088/ 72

Adding Script Manager

I have read many articles that talked about adding the Script Manager to the SharePoint manually; that you have to go to the master page of your SharePoint page, and then write a script manager tag to the HTML code manually!

Actually, I do not prefer this way. As a developer, I would like to add it dynamically by the code.

Go back to Listing 1 and take a look on OnInit subroutine. Here we will add the script manager dynamically. We are checking if there is an existing script manager on the page. If it is not, then we will create a new script manager and we will add it in the page controls.

Dealing with UpdatePanel and UpdateProgress

If you try to add controls to UpdatePanel programmatically, you will notice that the UpdatePanel requires you to add server controls only. So you need to choose the proper server control that matches your requirement after rendering time. For example, if you want to add HTML div inside the UpdatePanel, you should add the panel control instead of the HTML div element.

Since the UpdateProgress control is a template control, you have to create a template class that represents the container of the UpdateProgress controls. Listing 1 contains a public class called ProgressTemplate, I have created an instance from that class in CreateChildControls subroutine and then I have added the loading animation image inside the UpdateProgress using that instance.

To make our Ajax webpart more reusable, there is a public property called LoadingImageURL which enables you to set path of the loading animation image. So you can upload the image you want into your Sharepoint site, and then you can use it as loading image by using LoadingImageURL public property.

View Entire Article

User Comments

Title: Mr   
Name: Dinesh
Date: 2010-11-15 5:48:03 AM
Awesome code and I feel it is the best one for understanding Ajax in Sharepoint. But one small request can u write/give the code in C#. I will be very happy if u do this favor for me. Thanks a lot.
Title: Mr   
Name: James
Date: 2010-10-02 9:57:49 AM
Awesome code, and great references too. } Really thumbs up for the code, this is the best tutorial so far!
Will study how all of this works... =)
Title: Mr   
Name: Hiep
Date: 2010-06-18 12:47:50 AM
This article is useful. thanks much
Title: Mr   
Name: Jafari
Date: 2009-10-19 8:47:26 AM
Thanks Abdulla,
could you explain how to use ajax with multiple updatepanels?
Title: Mr   
Name: ashwin
Date: 2009-02-06 12:54:08 PM
Cool stuff
Title: Mr   
Name: Daniel Partridge
Date: 2009-01-21 5:02:39 AM
This looks really good!!!!
Title: Dan   
Name: Dan
Date: 2008-12-27 9:45:50 AM
Really Liked the oninit code.
Title: mrs   
Name: Madhuri
Date: 2008-12-15 4:32:54 PM
This is really very useful. Thanks

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-10-04 12:02:32 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search