Join Dotnetcodes DotnetCodes.com 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
ASP.net MVC Interview Questions Answers Interview Questions
Get Started Developing for Android Apps with Eclipse Articles
Serial Number in SSRS Articles
.Net framework 4.0 Interview Questions Answers Interview Questions
SQL server reporting services Interview Questions (SSRS) part 1 Articles
How to Print a Crystal Report direct to printer 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
Html5 interview questions and answers Interview Questions
SharePoint 2010 interview Questions Answers Interview Questions
Infosys Interview Questions Interview Questions
Dynamic Menu using HTML List Tag and CSS in ASP.Net Articles
Sql Server Database Backup and Restore through C# Source Codes
Populate or bind Dropdownlist in Asp.net using Jquery and Json Articles
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:2321
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)
{

base.OnInit(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 = @"_spBodyOnLoadFunctionN