I'm studying the PageRequestManager event lifecyle. It appears that when the number of times i click the linkbutton to perform the asynch postback, that same number of times the event is being called. Here's the scenario: I click the linkbutton once. Alerts for all events are called. I click the linkbutton once again. Alerts for all events are called twice. I click the linkbutton once again. Alerts for all events are called 3x. ... etc. Heres the sample code:
/*************************** aspx code ************************/
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="AsynchronousLifeCycle.js" />
</Scripts>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Date: "></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Push me!" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
/******** js code *************************************/
Sys.Application.add_load(ApplicationLoadHandler)
Sys.Application.notifyScriptLoaded();
function ApplicationLoadHandler(sender, args)
{
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(InitializeRequest);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoading);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}
function InitializeRequest(sender, args)
{
alert("InitializeRequest");
}
function BeginRequest(sender, args)
{
alert("BeginRequest");
}
function PageLoading(sender, args)
{
alert("PageLoading");
}
function PageLoaded(sender, args)
{
alert("PageLoaded");
}
function PageLoaded(sender, args)
{
alert("PageLoaded");
}
function EndRequest(sender, args)
{
alert("EndRequest");
}
hi,
Please refer below URL:
http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerBeginRequestEvent.aspx
Thanks
kishore
www.relgo.com.
No comments:
Post a Comment