February 17, 2008

AJAX Tips

Some of you may know how to disable ajax updates on the ScriptManager tag directly..

<asp:ScriptManagerID=”ScriptManager1″runat=”server”EnablePartialRendering=”false”/>

But did you know that you can also disable ajax for a specific content page?

protectedoverridevoid OnInit(EventArgs e)

{

base.OnInit(e);

ScriptManager.GetCurrent(this.Page).EnablePartialRendering = false;

}

If you want to find out if the page did an asynchronous postback or not, use this..

protectedvoid Page_Load(object sender, EventArgs e)

{

if (ScriptManager1.IsInAsyncPostBack)

{

Page.Title = "AJAX POSTBACK!";

}

}