Hi, In this post I describe that how to give alert msg on button click event using javascript.
For this I have take one Example as follow.
First of all take one .aspx form and put one text box and one button.
And then define the function Confitm() in between <head></head> tag as mention in example below.
And then call the function onClientClick event of button.
Example=>
For this I have take one Example as follow.
First of all take one .aspx form and put one text box and one button.
And then define the function Confitm() in between <head></head> tag as mention in example below.
And then call the function onClientClick event of button.
Example=>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AlerMsgUsingJavaScript.aspx.cs" Inherits="AlerMsgUsingJavaScript" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script language="javascript" type="text/javascript"> function Confirm() { var pre_qty; var pqty = document.getElementById("<%=txtbx_presentqty1.ClientID %>"); pre_qty = pqty.value; if (pre_qty != '') { return true; } else { alert('Enter Value'); return false; } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtbx_presentqty1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return Confirm()" /> </div> </form> </body> </html>OutPut=>
0 comments:
Post a Comment