2012年3月10日土曜日

run javascript after Updatepanel

perhaps you can attach to the EndRequestHandler. However this will run your javascript after every request:

<script language="javascript" type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args)
{
// Do your javascript here!!
}
</script>


oh, realy:)

but if I have 3-4 UpdatePanels & TimerControl, how I can different between reqests? For example I need run js functions f() just after UpdatePanel1 updated

10x


You can utilize the UpdatePanelAnimationExtender from the AJAX Control Toolkit. Download the toolkit and include it in your project, below is the following code necessary to do what you need.

Remember to register the toolkit dll assembly
<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Run Script after UpdatePanel</title>
</head>
<body>

<scripttype="text/javascript"language="javascript">
function RunAction() {
//Code here.
}
</script>

<ajaxToolkit:UpdatePanelAnimationExtender ID="ae"
runat="server" TargetControlID="UpdatePanel1">
<Animations>
<OnUpdated>
<Sequence>
<ScriptAction Script="RunAction();" />
</Sequence>
</OnUpdated>
</Animations>

</ajaxToolkit:UpdatePanelAnimationExtender
<asp:UpdatePanel Id="UpdatePanel1" runat="server">
<ContentTemplate>
Something here
</ContentTemplate>
</asp:UpdatePanel
</body>
</html>

This can be duplicated multiple times in the same page.

Have fun and Happy Thanksgiving.

JoeWeb



wow!!!
its very good solution. thank you!

may be you know how I can ascribe "atlas:UpdateProgress" for specific UpdatePanel?:) because I have on some page UpdatePanel and TimerControl, but every time when occur Timer event TICK then i see UpdateProgress image, and I need it when UpdatPanel updated only.
10x


JoeWeb:

You can utilize the UpdatePanelAnimationExtender from the AJAX Control Toolkit. Download the toolkit and include it in your project, below is the following code necessary to do what you need.

Remember to register the toolkit dll assembly
<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

its work with AJAX Control Toolkit, but I work in my site with Atlas & Atlas Control Toolkit

how i can do some with atlas?
10x


In order to use the Animation Extenders you have to download the latest Control Toolkit.

Other than that you would have to figure out some other way to capture when a certain update panel finishes updating and then fire the javascript function.

The code that I gave would be the simpliest and easiest solution to your problem, however it would mean you need to upgrade to the Ajax Control Toolkit and Ajax Beta 1 or 2.

JoeWeb


I started to use AJAX Control Toolkit and wrote code as your example.

I put alert() in<ScriptAction Script="alert();" /> and I see message every time that timer event fire ( I not call toUpdatePanel1.Update() in Timer Tick event)

asp:UpdatePanel has attributeUpdateMode="Conditional"

0 件のコメント:

コメントを投稿