ScriptManager.RegisterStartupScript弹不出来

来源:互联网 发布:client mac addr解决 编辑:程序博客网 时间:2024/04/19 11:24

 ScriptManager.RegisterStartupScript(this, this.GetType(), null, "alert('" + ex.Message + "');", true);

1、在aspx文件里加一个EnableEventValidation="false"

 

2、加一个Tigger

  <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />

        </Triggers>

 

3、确保该aspx文件里面有ScriptManager

母版页里有而该页面里面没有也是不行的

 

4、要弹出的字符串中有一些特殊的字符 如:单引号

string str="as'as'";

str=str.Replace("'","\"");

然后弹出该字符串