Monday, March 26, 2012

detect when updatepanel has returned in javascript

Hi

I have this code which detects when an updatepanel has returned

Sys.Application.load.add( onLoad );

function

onLoad()

{

var page = $object("_PageRequestManager");

page.propertyChanged.add( changed );

}

function

changed( obj,args )

{

if (args.get_propertyName() && obj.get_inPostBack() ==false)

{

var mode = document.getElementById('<%=siteMode.ClientID %>');//so something

}

}

Is there anyway to tell if a specific update panel was activated on a particular postback and then do something when it has finished its callback.

thanks

andrea

Have you found a solution? I am also looking for the solution, and want to add one more sample here so maybe someone experienced can help (I found the code somewhere (maybe on this forum) and slightly extended it):

<%@. Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void h(object s, EventArgs a) {txt.Text = DateTime.Now.ToString();}void h1(object s, EventArgs a) {txt1.Text = DateTime.Now.ToString();}</script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <atlas:ScriptManager runat="server" id="manager" EnablePartialRendering="true"></atlas:ScriptManager> <atlas:UpdatePanel runat="server" ID="panel"> <ContentTemplate> <asp:Literal runat="server" ID="txt" /> <asp:Button runat="server" ID="bt" OnClick="h" Text="try" /> </ContentTemplate> </atlas:UpdatePanel> <atlas:UpdatePanel runat="server" ID="pane2"> <ContentTemplate> <asp:Literal runat="server" ID="txt1" /> <asp:Button runat="server" ID="bt1" OnClick="h1" Text="try1" /> </ContentTemplate> </atlas:UpdatePanel> </form> <script type="text/javascript"> Sys.Application.load.add( onLoad );function onLoad() {var page = $object("_PageRequestManager"); page.propertyChanged.add( changed );}function changed( obj, args ) {if( args.get_propertyName() == "inPostBack" && obj.get_inPostBack() == false) {alert("refreshed" ); }}</script> </body> </html>

Extending my previous post:

so hove in javascript function "changed" we can know what update panel: panel on pane2 caused call of the javascript function?


Hi

I still havent found a solution either

andrea


Hi,

unfortunately there isn't a solution at the moment. Actually, the ID of the panel that triggered the async postback is contained in the _postbackSettings object of the PageRequestManager, but this is an object that cannot be accessed from outside.

Thus, the only possibility is to modify the source code and create a property that returns the _postbackSettings object. I hope that the team will do this in one of the next releases.

No answer, but possibly related posts have been compiled near the end of this...

http://forums.asp.net/AddPost.aspx?PostID=1373674


hi

that link takes me to a page for adding a new post

thanks


ah, so it does...perhaps this is better...

http://forums.asp.net/thread/1356742.aspx

No comments:

Post a Comment