The integration of ASP. NET Ajax with SharePoint can greatly improve user experience, so it is easy to implement. This article integrates ASP. NET Ajax with the previous webpart example.
The key to integrating ASP. NET Ajax with Sharepoint is the configuration file. ( Note: ASP. NET Ajax 3.5 is used here. If 1.0 is used, it should be fine. No test is performed. )
Add a reference to system. Web. Extensions.
Program Code : Textbox txt1 = New Textbox ();
Dropdownlist ddl1 = New Dropdownlist ();
Textbox txt2 = New Textbox ();
Htmlgenericcontrol lbl1 = New Htmlgenericcontrol ( " Span " );
Textbox txt3 = New Textbox ();
Button btn1 = New Button ();
Htmlgenericcontrol lbl2 = New Htmlgenericcontrol ( " Span " );
protected override void createchildcontrols ()
{
txt2.width = ddl1.width = txt1.width = 40 ;
ddl1.items. add ( " + " );
ddl1.items. add ( " - " );
ddl1.items. add ( " * " );
ddl1.items. add ( " / " );
Lbl1.innerhtml= "=";
Btn1.text= "Calculate";
Btn1.click+ = NewEventhandler (btn1_click );
Lbl2.style. Add ("Color","Red");
//Add scriptmanager and updatepanel to put the control in updatepanel.
Scriptmanager Sm= NewScriptmanager ();
This. Controls. Add (SM );
Updatepanel up= NewUpdatepanel ();
Up. contenttemplatecontainer. Controls. Add (txt1 );
Up. contenttemplatecontainer. Controls. Add (ddl1 );
Up. contenttemplatecontainer. Controls. Add (txt2 );
Up. contenttemplatecontainer. Controls. Add (lbl1 );
Up. contenttemplatecontainer. Controls. Add (lbl2 );
Up. contenttemplatecontainer. Controls. Add (btn1 );
This. Controls. Add (up );
}
The configuration file is complex. A simple method is to create a new one. net 3.5 web application, which itself supports ASP. net Ajax 3.5, you only need to put the web of this web application. config and the Web. you can merge the configurations.
After compilation and deployment, you can see that the new operations can be skipped.
Download example: Click to download
Floating remote blog: http://www.cnblogs.com/zxjay/
Author: piaoyao (Zhou Zhenxing)