You must use a ScriptManager control on a page to enable the following Microsoft Ajax features of ASP.NET:
Client-script functionality of the Microsoft Ajax Library, and any custom script that you want to send to the browser.
Partial-page rendering, which enables regions on the page to be independently refreshed without a postback. The ASP.NET UpdatePanel, UpdateProgress, and Timer controls require a ScriptManagercontrol in order to support partial-page rendering.
JavaScript proxy classes for Web services, which enable you to use client script to access Web services and specially marked methods in ASP.NET pages. It does this by exposing the Web services and page methods as strongly typed objects.
- JavaScript classes to access ASP.NET authentication, profile, and roles application services.

If someone clicks the Button in this setup, the Button control will raise a postback event that will be caught by the UpdatePanel control. The UpdatePanel then resubmits the postback event as a partial postback and its content will be asynchronously updated (without the browser fully reloading the page).
However, there are many interesting scenarios where your expectations will fail, leaving you with a mess on your hands.
protected void Button1_Click(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript( this.GetType(),"myscript","alert('hello world!');"); }protected void Button1_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript( this,this.GetType(),"myscript","alert('hello world!');",true); } 
you want to click the LinkButton and make the UpdatePanel behave as if the LinkButton were inside it. To do this, use a method on the ScriptManager control called RegisterAsyncPostBackControl:
protected void Page_Load(object sender, EventArgs e) { // register the LinkButton1 control as one that can // cause partial postbacks. ScriptManager1.RegisterAsyncPostBackControl(LinkButton1); } protected void Page_Load(object sender, EventArgs e) { // Button1 will cause a full post-back no matter // where it is on the page. ScriptManager1.RegisterPostBackControl(Button1); }protected void Calendar1_SelectionChanged(object sender, EventArgs e) { ScriptManager1.RegisterDataItem( Label1, Calendar1.SelectedDate.ToShortDateString()); }ScriptManager and ScriptManagerProxy :-
The ScriptManager is the most important control for an Ajax enabled web page. It provides Client side scripting and access to web service using javascript proxy classes. Using the UpdatePanel control provides partial page rendering capabilities. There can be only one ScriptManager control in an Ajax enabled webpage. If more than one ScriptManager control is added in the web page, the following exception will occur at runtime: “Exception Details: System.InvalidOperationException: Only one instance of a ScriptManager can be added to the page.
However to modify the ScriptManager control of the master page, then have a scriptManagerproxy control in the content page. Note that to use ScriptManagerProxy control in the content page, there should be a ScriptManager control in master page.
Source:-
http://msdn.microsoft.com/en-us/magazine/cc163354.aspx (a Very Good Link)
http://msdn.microsoft.com/en-us/library/bb398863.aspx
No comments:
Post a Comment