how to display alert box in asp.net

前端 未结 4 509
梦谈多话
梦谈多话 2021-01-06 17:01

i have a registration page with a submit button.

i want to show an alert box when the \"user clicks on the submit button\" after which the \"data entered by the user

相关标签:
4条回答
  • 2021-01-06 17:36

    alerts should be alert. if you are using ajax, better use ScriptManager.

    0 讨论(0)
  • 2021-01-06 17:38

    Did you mean for the javascript to be "alerts("+ str + "');" and not "alert(" + str + "');"?

    0 讨论(0)
  • 2021-01-06 17:49

    alerts:

    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alerts('" + str + "');", true);
    

    needs to be alert:

     Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + str + "');", true);
    
    0 讨论(0)
  • 2021-01-06 17:53

    Regular Page

    public void ErrorTrap(string str)
    {
       Page.ClientScript.RegisterStartupScript(this.GetType(), "alert" + UniqueID, 
         "alert('" + str + "');", true);
    }
    

    Ajax Page

    You need to use ScriptManager if you use ajax.

    public void ErrorTrap(string str)
    {
       ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert" + UniqueID, 
          "alert('" + str + "');", true);
    }
    
    0 讨论(0)
提交回复
热议问题