开发者

executing one line of javascript on asynchronous ajax event in ASP.NET

开发者 https://www.devze.com 2023-03-12 20:55 出处:网络
I am using the Elastic CSS framework on an ASP.NET site. It is doing a great job of sizing the various containers I have until an UpdatePanel executes a partial postback. The solution as I understand

I am using the Elastic CSS framework on an ASP.NET site. It is doing a great job of sizing the various containers I have until an UpdatePanel executes a partial postback. The solution as I understand it is to execute the following line of javascript

Elastic.refresh();

I'm pretty good with C# and ASP.NET but not so much with javascript. As I understand it, RegisterStartupScript only registers the script, I still need a control to then execute it.

So how can I get this one line of javascript to execute when a custom control catches a custom exception and cause开发者_C百科s a partial postback?


Edit

In javascript on your page you could also try something like this

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);
function PageLoadHandler()
{
    Elastic.refresh();
}

This handler will run after any callback but sender._postBackSettings.panelID will allow you to filter it to the panel you want.

Alternativly you could try if end request fits your needs better.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function PageLoadHandler()
{
    Elastic.refresh();
}

Original

Do you have a ScriptManager control on the page that has the UpdatePanel? If so you might be able to leverage the ScriptManager.AsyncPostBackError and have it execute your method.

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.asyncpostbackerror.aspx


This is a guess, but I'd try using a literal control w/in the ajax panel that contained the following:

<script language="javascript">
Elastic.refresh();
</script>

If I'm right the Ajax panel will reload and that will automatically execute that line of code when it does.

0

精彩评论

暂无评论...
验证码 换一张
取 消