Pop up alert message box in ASP.NET C#,
We can get pop up alert message box using below code :-
Code :-
string message = "welcome in code solution";
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true);
For more
understanding , I am giving here this example:-
Source Code:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnmsgbox" runat="server" onclick="btnmsgbox_click"
Text="Alert pop up message box " />
</div>
</form>
</body>
</html>
Code behind (c#):-
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebControls;
public partial class alert : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
}
protected void btnmsgbox_click(object
sender, EventArgs e)
{
string
message = "welcome in code solution";
ClientScript.RegisterStartupScript(GetType(), "alert",
"alert('" + message + "');", true);
}
}
Out-put:-
Pop up alert message box in ASP.NET C#,
Reviewed by NEERAJ SRIVASTAVA
on
2:53:00 PM
Rating:
No comments: