Join Dotnetcodes is online Discussion Forum for Software professionals . It lets you find friends around the world and Create professional network that share similar interests as you. Get help on ur projects by industry specialists. Also get answers to all ur technical/placement related querries.Get an edge over others.
Already MemberClick here to login MVC Interview Questions Answers Interview Questions
Serial Number in SSRS Articles
Get Started Developing for Android Apps with Eclipse Articles
How to Print a Crystal Report direct to printer Articles
Razor View Engine Interview Questions Answers Interview Questions
.Net framework 4.0 Interview Questions Answers Interview Questions
SQL server reporting services Interview Questions (SSRS) part 1 Articles
Whats New in ASP.NET 4.0 Part 2 Articles
Difference between Encapsulation and Abstraction Interview Questions
Explaining SDLC -System Development Life Cycle Articles
SPIRE PDF Library Articles
Infosys Interview Questions Interview Questions
Html5 interview questions and answers Interview Questions
Dynamic Menu using HTML List Tag and CSS in ASP.Net Articles
SharePoint 2010 interview Questions Answers Interview Questions
Submit Articles | More Articles..

How to use Ajaxtoolkit 3.5 in SharePoint webpart and User control

Posted By: rakesh On:11/19/2010 12:33:36 AM in:Articles Category:ASP.NET Hits:2739
This post will be a step-by-step tutorial about how to use ajaxtoolkit 3.5 in your sharePoint webpart or usercontrol. In the below example i am using a web user control that is loaded by a custom weboart created using vsewss( you can create wspbuilder or can create it manually). 

This post will be a step-by-step tutorial about how to use ajaxtoolkit 3.5 in your sharePoint webpart or usercontrol. In the below example i am using a web user control that is loaded by a custom weboart created using vsewss( you can create wspbuilder or can create it manually). 

Things to Note - All the modifications to enable ajax and use ajaxtoolkit are made in the webpart not usercontrol. This way you can use controls like Popupextender in your webpart's createchildcontrols or in your web user control.

Steps are :

1. Download AjaxToolKit 3.5

2. Drag and drop the Ajaxtoolkit.dll in GAC.

3. Make Changes in your SharePoint webapp's web.config. For changes see the Post Here. Follow Step 3 only.
(Side Note : Recycle the app pool after making Web.Config changes. If you have multiple WFE's do it on all the front ends).

4. After you have added the references in web.config its the time to make changes in your webpart. Add the following code in your webpart.

protected override void OnInit(EventArgs e)

if (this.Page.Form.FindControl("scriptManager1") == null){

if (AjaxControlToolkit.ToolkitScriptManager.GetCurrent(Page) == null)
AjaxControlToolkit.ToolkitScriptManager toolkitScriptManager = new AjaxControlToolkit.ToolkitScriptManager();

toolkitScriptManager.ID = "scriptManager1";

this.Page.Form.Controls.AddAt(0, toolkitScriptManager);

and the following method to fix the updatepanel postbacks

private void EnsurePanelFix()
if (this.Page.Form != null)
String fixupScript = @"_spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
function _initFormActionAjax()
if (_spEscapedFormAction == document.forms[0].action)
document.forms[0]._initialAction = document.forms[0].action;
var RestoreToOriginalFormActionCore = RestoreToOriginalFormAction;
RestoreToOriginalFormAction = function()
if (_spOriginalFormAction != null)
document.forms[0]._initialAction = document.forms[0].action;
typeof(YOUR WEBPART NAME), "UpdatePanelFixup", fixupScript, true);

now make call to EnsurePanelFix in your CreateChildControls method like below 

protected override void CreateChildControls()



// Since i am loading a user control in my webpart i am using below to add it.
userControl = (UserControl)Page.LoadControl(@"/_controltemplates/MyCustomUserControl.ascx");


At this point you should be all set to use your ajaxtoolkit controls in your webparts CreateChildControls(like any other control). In my case all my Ajax controls were used in my Web User Control. 

5. (Optional) Add the following references in the ascx file of your Web user control.

<%@ Register Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" Namespace="System.Web.UI" TagPrefix="asp" %> 

<%@ Register Assembly="AjaxControlToolkit, Version=3.5.40412.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>

don't forget to add the references for ajaxtoolkit assembly in your webpart and user control.
Happy SharePointing! 

comments powered by Disqus
User Profile
Rakesh Sinha
Sr. Technical Lead
New Delhi , India
Email :You must Log In to access the contact details.
Latest Post from :rakesh
Which party you want to vote in Loksabha elections 2019?
View: 692 | Submitted on: 10/12/2018 5:59:06 PM
Response.Redirect vs Server.Transfer
View: 484 | Submitted on: 12/27/2015 2:26:38 PM
The test form is only available for requests from the local machine.
View: 716 | Submitted on: 11/3/2015 9:54:36 PM
Difference between web service WCF and Web API
View: 7677 | Submitted on: 10/28/2015 9:23:51 PM
Which party you want to vote in Delhi assembly elections 2015?
View: 1907 | Submitted on: 12/18/2014 4:19:24 AM
Submit Articles | All Post of This User..

All rights reserved to dotnetcodes. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
Best viewed at 1024 x 768 resolution with Internet Explorer 5.0 or Mozila Firefox 3.5 or Google Crome and higher