I am using MessageBox class in Asp.NET with C# by imposing the namespace
using System.Windows.Forms
I have the following code:
/* Method for displaying the Message Box */
public void MsgBox()
{
string message = "Do you want to modify the rate list?";
string caption = "";
MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
DialogResult result;
result = MessageBox.Show(message, caption, buttons);
if (result == DialogResult.Yes) {
Response.Redirect("PaperRateList.aspx");
}
}
/*Calling of the above method in the following event */
protected void Save_Click(object sender, EventArgs e)
{
CompanyMaster_Insert();
RateList_Save();
MsgBox(); /*method*/
}
Now the problem is that the message box is appearing behind the form in minimized mode.and the form can be closed before closing the message bos.I want this messagebox on the form and i want to close the form after closing the message box.
MessageBoxin web environment is not the best path to go, as it’s a cheap way of implementing a windows form feature.You have 2 ways to do this, server side (if you need to process some data) or client side (if you have all the data in the page and you can process it using javascript).
For you particulary example, you probably have a submit button like:
try to add this:
so it ends up like:
That’s just using a javascript method called
confirm.To make nice MessageBox examples, and to avoid the user not to mess up with the page while the message is visible, it’s called Modal Dialog or Modal Window, try to search for it…
jQuery UI has a Modal element that you can use, and if you fancy AJax stuff and you’re a beginner in ASP.NET, I strongly suggest you to try the ASP.NET Control Toolkit