zl程序教程

您现在的位置是:首页 >  前端

当前栏目

webform运行时弹出JavaScript的alert窗口

JavaScript 运行 窗口 ALERT WebForm
2023-09-11 14:14:21 时间

 

 https://stackoverflow.com/questions/9720143/asp-net-web-application-message-box

 

Or create a method like this in your solution:

public static class MessageBox {
    public static void Show(this Page Page, String Message) {
       Page.ClientScript.RegisterStartupScript(
          Page.GetType(),
          "MessageBox",
          "<script language='javascript'>alert('" + Message + "');</script>"
       );
    }
}

Then you can use it like:

MessageBox.Show("Here is my message");

 

public static void PageAlert(Page objPage, string strContent)
{
objPage.ClientScript.RegisterClientScriptBlock(objPage.GetType(), "alert", "<script type='text/javascript'>window.alert('" + strContent + "');</script>");
}