ASP.NET - message box in asp.net
Asked By kalaiarasi rengan on 18-May-09 01:31 AM
how to use message box in asp.net with c#.
In message box , If i click Ok it should do some actions,
If i click Cancel it should do some other actions.
Try This...
Prakash C replied to kalaiarasi rengan on 18-May-09 01:35 AM
try this...
Page.RegisterClientScriptBlock("test", "<script> alert('ur message'); </script>");
hope this helps... :-)
Vasanthakumar D replied to kalaiarasi rengan on 18-May-09 01:38 AM
Use this method for it
Kalit Sikka replied to kalaiarasi rengan on 18-May-09 01:38 AM
public static string GetAlert(string Message)
{
string Script = "";
Script += "<script language=JavaScript>\n";
Script += "alert('" + Message + "') \n";
Script += "</script>";
return Script;
}
I code behind:
Script = VetCareUtilities.GetAlert("File does not exists");
Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script);
Santhosh N replied to kalaiarasi rengan on 18-May-09 01:39 AM
You do not have inbuilt message box like you have in windows application (which I am sure you are fully aware of...)
For this, you need to have a javascript confirm box and customize this to trigger from server side code using hidden fields and client register events..
Check this one with the above said implementation..
http://www.codeproject.com/KB/webforms/NingLiangSimpleControl.aspx
and
http://www.c-sharpcorner.com/UploadFile/mahesh/WebMsgBox09082006110929AM/WebMsgBox.aspx
Alice J replied to kalaiarasi rengan on 18-May-09 01:49 AM
This link should do a great help!
http://www.4guysfromrolla.com/articles/021104-1.aspx
check this
sri sri replied to kalaiarasi rengan on 18-May-09 01:53 AM
hi,
try the below code
<asp:button onclientclick="return confirm('Are you sure want to Delete');"
---- />
check this
sri sri replied to kalaiarasi rengan on 18-May-09 01:55 AM
hi,
try the below code
<asp:button onclientclick="return confirm('Are you sure want to Delete');"
---- />
how to display the user name inside the confirm box
kalaiarasi rengan replied to sri sri on 18-May-09 02:21 AM
how to display the user name inside the confirm box
RE
Ravenet Rasaiyah replied to kalaiarasi rengan on 18-May-09 02:27 AM
Hi
You can also use the AJAX Conformation box also.
Add ajax to your project then make your html code
<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server"
TargetControlID="LinkButton1"
ConfirmText="Are you sure you want to click this?"
OnClientCancel="CancelClick" />
more information here
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ConfirmButton/ConfirmButton.aspx
thank you
user name in confirm box
sri sri replied to kalaiarasi rengan on 18-May-09 03:15 AM
hi,
try the below code to display the username in the confirmbox
try the below code
<asp:button onclientclick="return confirm('Are you sure want to Delete <%=Session["username"]%>');"
---- />
Ignore my previous post. try this code
sri sri replied to sri sri on 18-May-09 03:22 AM
hi,
try the below code in the code behind
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "return confirm('Are you sure want to Delete " + Session["username"] + "');");
---
---
---
}
thank u
kalaiarasi rengan replied to sri sri on 19-May-09 03:13 AM