In this post I’m going to explain how to start using ajax in your web parts. The goal of this article is to reproduce functionality similar to the KPI and BDC web parts in MOSS 2007.
Introduction
I am going to show you how to integrate ASP.NET Ajax 1.0 with MOSS 2007. I will create a new Ajax WebPart from scratch and then deploy it into MOSS 2007 site. Moreover, I will demonstrate how to add that webpart into SharePoint Page.
Building Webpart DLL Project
To create a web part, open your visual studio, create new “Proejct“, Select “SharePoint” from “Project Types” and select “Web Part” from Templates. Give the name of Web Part “AjaxSample” in “Name” Field. Then Press “OK“.
Now you can see the code window like :
Now Add the reference for Ajax DLL :
Open Solution Explorer – Right click on “References” and select the “AjaxControlToolkit.dll” from your desired location where you have stored it. After adding the required references your solution explorer will have the look , like
Now its time to extend web.config with some settings to enable ASP.NET AJAX technology.
Extending SharePoint web.config files with ASP.NET AJAX requires that you interleave some Ajax registration entries in-line with WSS registration entries.
To do this you will need to edit your SharePoint web.config file.
1. Add a “sectionGroup” element to the “configSections” tag:
2. Add a “controls” section as a child of the “system.web” “pages” tag.
3. Add the following tag to the tag, within :
4. Add some new registrations to the end of the section:
5. Add a new registration to the HttpModules section, beneath any existing registrations.
6. Add a SafeControl entry for the System.Web.UI namespace from Microsoft Ajax Extensions, within the section:
7. Finally, add the following configuration tags at the bottom of web.config, near the bottom before the end tag.
8. Now add references:
using System;
using System.Collections;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI;
9. Take two controls Label and TextBox :
private Label label;
private TextBox textBox;
10. Now create CreateChildControls() Method:
11. Write below line of code in Button’s Click event:
this.label.Text = “Hello ” + this.textBox.Text;
12. Now add one method EnsureUpdatePanelFixups() :
13. Now add the ScriptManager in your Web Part :
Define the Script Manager like :
protected ScriptManager SM;
14. Then put below code in the beginning of CreateChildControl() Method:
15. Now deploy the Web Part in your SharePoint Site.









