RegisterStartupScript doesn't work with ScriptManager,Updatepanel. Why is that?

前端 未结 4 1584
不知归路
不知归路 2020-11-29 03:31
protected void timer1_Tick(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in rpChat.Items)
        {
            TextBox txt = item.FindControl         


        
4条回答
  •  野性不改
    2020-11-29 03:43

    When you use an UpdatePanel, then you can not call JavaScript using ClientScript as you have tried to. You have to use ScriptManager.RegisterStartupScript instead.

    So change your

    Page.ClientScript.RegisterStartupScript(this.GetType(), "myKey", javaScript);
    

    to

    ScriptManager.RegisterStartupScript(updatePanelId,updatePanelId.GetType(), "alert", javaScript, true);
    

提交回复
热议问题