Monday, March 26, 2012

Updatepanel / Client-Script problem

Hello,
I have a problemL
on my ContentPage(Masterpage/Contentpage-Concept) I have an Updatepanel with a couple of Controls on it. One Button of this Controls generate a Word-Document und download it to the Client. My Solution for this was in the earlier Version:
In the Click-Event on server side I registered 2 Client-Scripts.

sMsg =" function Timer(){ if (confirm(""" & sMsg &""") == true){ document.getElementById(""ctl00_CP1_MsgBox"").click();}}"

Page.ClientScript.RegisterStartupScript(Me.GetType,"msg", sMsg,True)

Page.ClientScript.RegisterClientScriptBlock(Me.GetType,"Timer"," window.setTimeout('Timer()', 50)",True)

This Scripts trigger an ClickEvent on a Button outside an Updatepanel and in his Eventhandler I create the Word-Document and send it to the Client. This works fine but now with the new CTP it doesn’t work. I try different Things

(register the Script on Sriptmanager

Dim SRefAsNew Microsoft.Web.UI.ScriptReference

SRef.Path ="~/Scripts/Script.js"

SRef.ScriptMode = Microsoft.Web.UI.ScriptMode.Auto

SMProxy.Scripts.Add(SRef)

or use the PostBackTrigger instead of an AsyncPostBackTrigger

<asp:PostBackTriggercontrolid="btnEditReport"/>

. But still don’t work. The Timer-Script starts and call the function Timer() but the Control-Reference points to NULL.

The option to put the Button outside an UpdatePanel it’s not really the Solution for me, then I use the same Concept for Messageboxes. And these also don’t work with the new CTP

now…I hung…any Solutions?

Thanks.

You now have to register your client scripts through the ScriptManager control (they have static methods that mimic ClientScript). Unfortunately, as I've found - this has a lot of backwards compat issues as well as ordering, ie registering arrays & script includes will render the arrays prior to script includes - which is different than the asp.net way.

No comments:

Post a Comment