[英]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
我的ASP.NET頁面上有這個代碼。 當我單擊我的網頁上的按鈕時,此彈出窗口應該會顯示出來。 問題是有時它出現在前台,但有時我必須實際點擊文檔上的小圖標。
有任何想法嗎?
將服務器端對話框顯示為Web應用程序的一部分是不常見的。 這將阻止Web服務器的線程,並且用戶(除非他們坐在Web服務器控制台,而不是在他們的家/辦公室使用Web瀏覽器)將看不到它。
我想你想做一個客戶端彈出窗口 - 可能有一個javascript Alert或HTML對話框。
不要使用MessageBox。
如果需要從代碼隱藏中激活JavaScript警報消息,請嘗試使用ScriptManager。
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "clientScript", "alert('hi');", true)
上面的代碼使用頁面注冊腳本並觸發警報消息。 最后一個參數true表示標簽將在您提供的腳本周圍打開和關閉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.