[asp-classic] Display MessageBox in ASP

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?

This question is related to asp-classic

The answer is


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

<!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.


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

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