calling Javascript function from c# in updatePanel problem

I

imbirek8

Hi! I would like to call Javascript function from code behind.
Everything was working until I put UpdatePanel. Why this code is not
working any more ? How to repair it ?

<head runat="server"><title></title>
<script type="text/javascript"> function aaa(){ alert('hello');}
</script>
</head>
<body><form id="form1" runat="server"><div>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div></form></body></html>
<asp:ScriptManager ID="smHfhr" runat="server"></asp:ScriptManager>

protected void Button1_Click(object sender, EventArgs e)
{
if (!ClientScript.IsClientScriptBlockRegistered("mytest"))
ClientScript.RegisterClientScriptBlock(this.GetType(), "mytest",
"<script>aaa();</script>");
}

Thanks for help
 
B

bruce barker

ClientScript only render on the original page. you need to use ScriptManager
if you want javascript rendered in an update panel

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top