Use JavaScript alert() box in ASP.Net

In this asp.net article i will explain how to use javascript alert box in asp.net.

we use alert box mostly for a giving a warning message to user.
we use alert box for validation purpose, if there is empty textbox while submitting form we display message in alert box enter some value.

Here we will learn with an ASP.Net Example.

Write javascript alert() box code in <head> tags like below :

<head runat=”server”>
<script type=”text/javascript” language=”javascript”>
function mm()
{
alert(“Hi Meera Academy”);
}
</script>
</head>

First Design asp.net web form for learn javascript alert() box.

JavaScript alert() box in asp.net
JavaScript alert() box in asp.net

Here is the asp.net Button control code :

 <asp:Button ID=”Button4″ runat=”server” Font-Bold=”True”
Text=”JavaScript Alert()” onclientclick=”mm()” Height=”35px” />

Here we use onclientclick property of button control for call javascript function.

JavaScript alert() box in asp.net
JavaScript alert() box in asp.net

I hope this asp.net example of use alert box will help you…

Leave a Reply

Your email address will not be published. Required fields are marked *