Display MessageBox in ASP

本秂侑毒 提交于 2019-12-29 06:50:12

问题


I am new to code and starting with ASP. How do I create a simple message box so I can alert the users on the web page?


回答1:


Here is one way of doing it:

    <%
       Dim message    
       message = "This is my message"
       Response.Write("<script language=VBScript>MsgBox """ + message + """</script>") 
    %>



回答2:


<% response.write("<script language=""javascript"">alert('Hello!');</script>") %>



回答3:


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
    alert("Hello!");
}
</script>

</body>
</html>

Copy Paste this in an HTML file and run in any browser , this should show an alert using javascript.




回答4:


If you want to do it from code behind, try this:

System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Message');", true);


来源:https://stackoverflow.com/questions/956977/display-messagebox-in-asp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!