calling Javascript function from c# in updatePanel problem



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');}
<body><form id="form1" runat="server"><div>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
<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",

Thanks for help

bruce barker

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

-- bruce (

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