ashkufaraz
ashkufaraz

Reputation: 5297

update panel with ClientScriptManager

<asp:button runat="server" id="a" onClick="a_Click"/>    

code

protected void a_Click(object sender, EventArgs e)
{   
    ClientScriptManager cs = Page.ClientScript;
    string script = "PanelVisiable($('#base')); ";
    script += "$('#message').text(' message  ');";
    script += "$('#message').dialog({modal:true,resizable:false,title:'پیغام',height:80,show:'clip',hide:'explode'});";
    cs.RegisterStartupScript(Page.GetType(), "", script, true);

}

this code work fine


but this

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
  <asp:UpdatePanel ID="UpdatePanel3" runat="server"><ContentTemplate>
 <asp:button runat="server" id="a" onClick="a_Click"/>
 </ContentTemplate></asp:UpdatePanel>

code

protected void a_Click(object sender, EventArgs e)
{   
    ClientScriptManager cs = Page.ClientScript;
    string script = "PanelVisiable($('#base')); ";
    script += "$('#message').text(' message  ');";
    script += "$('#message').dialog({modal:true,resizable:false,title:'پیغام',height:80,show:'clip',hide:'explode'});";
    cs.RegisterStartupScript(Page.GetType(), "", script, true);

}    

but this script does not work

Upvotes: 0

Views: 2277

Answers (2)

jdavies
jdavies

Reputation: 12894

Try using ScriptManager.RegisterStartupScript() method.

See the following MSDN documentation: ScriptManager.RegisterStartupScript()

It states:

Registers a startup script block for a control that is inside an UpdatePanel by using the ScriptManager control, and adds the script block to the page.

Upvotes: 3

IUnknown
IUnknown

Reputation: 22448

Use ScriptManager.RegisterStartupScript instead of ClientScript.RegisterStartupScript

Upvotes: 1

Related Questions