To understand this ATLAS issue imagine there is a page which
has an asp:button control and corresponding handler, which is called when the
button is clicked. The requirement is to show the alert window, when the button
‘cmd’ is clicked. To do that the handler
function ‘cmd_Click’ register the client script block by calling of RegisterStartupScript (the same issue can be noticed by
using of RegisterClientScriptBlock
too). This pattern is mostly
when som pop-up windows have to be opened.
<asp:Button ID="cmd " runat="server"
OnClick="cmd_Click"
/>
protected void
cmd_Click(object sender, EventArgs e)
{
string
script = @"<script
language=""javascript"">
alert(‘hello’)</script>";
if
(IsPostBack){
this.ClientScript.RegisterStartupScript(this.GetType(),
"ShowPopup", script);
}
}
}
If the same ASP.NET code is inserted in the atlas:UpdatePannel
control the alert-window will not appear.
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Always">
<ContentTemplate>
<asp:Button ID="cmd " runat="server" OnClick="cmd_Click" />
</ContentTemplate>
</atlas:UpdatePanel>
The generated script code should usually appear at the buttom
of the HTMP page:
<script language="javascript">
alert("2");
</script>
However the generated script looks different when update
pannel is used:
<script language="javascript">
<![CDATA[alert("2")]]>
</script>
This is a reason, why the script is not executed. Currently
the only way (I know) to workaround this problem is to avoid using of the
button-control with UpdatePanel.
Posted
Jul 20 2006, 12:00 PM
by
Damir Dobric