简体   繁体   中英

Message box popup in the background

String message = "Are you sure the event: \"" + event_text + "\" has been complete for Loan# " + loannumber + "?"; //show popup to confirm the completion of event

var result = System.Windows.Forms.MessageBox.Show(message, "Loan # "+loannumber+" - Processed Event: "+event_text, System.Windows.Forms.MessageBoxButtons.YesNo);

if (result == System.Windows.Forms.DialogResult.No)
{

    //do nothing close popup
}
else
{

//do something else

I have this code behind on my ASP.NET page. When I click a button on my webpage, this popup should show up. The problem is that sometimes it shows up in the foreground, but sometimes I have to actually click on the little icon on the doc.

Any ideas?

It is unusual to show a server side dialog as part of a web application. That will block the thread for the web server, and the user (unless they are sitting at the web server console, rather than in their home/office with a web browser) won't see it.

I think you want to do a client side popup - perhaps with a javascript Alert or a HTML dialog box.

Do not use a MessageBox.

If you need to fire a JavaScript alert message from the code-behind, try using the ScriptManager.

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "clientScript", "alert('hi');", true)

The code above uses the page to register the script and fire off the alert message. The final parameter true , indicates the the tags will open and close around the script you provided.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM