MessageBox.Show()是否确认? [英] MessageBox.Show() with Yes or No confirmation?
问题描述
MessageBox.Show(),Windows窗体应用程序中显示是或否确认对话框。现在我想要显示与aspx.cs页面中的相同...我在这里添加了哪个命名空间?
如果我引用System.Windows.Forms命名空间..我收到错误?
Windows应用程序的此代码..
< pre lang =vb> DialogResult result = MessageBox.Show( 是否要保存更改?, 确认,messageBoxButtons.YesNoCancel);
if (result == DialogResult.Yes)
// ... ...
else if (result == DialogResult.No)
// ...
else
//...
但是在aspx页面我可以写吗?请帮帮我?
这可能对你有帮助..
http://aspsnippets.com/Articles/ Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx [ ^ ]
使用jQuery插件例如 jqueryui [ ^ ],易于定制&浏览器兼容。
试试这个js函数: -
function confirmBrSave(){
var ans = confirm(' 你想要吗?保存这些数据?');
if (ans == true ){
return true ;
}
其他 {
return 假跨度>;
}
}
并从代码后面调用如下: -
ScriptManager.RegisterClientScriptBlock(Me.Page,GetType(String),overlay,confirmBrSave();,True)
MessageBox.Show() with Yes or No confirmation dialog box displayed in Windows Forms Application..Now I want to Shows as same as in aspx.cs page...Which namespace i added here?
If i reference System.Windows.Forms namespace..I get an error?
This code for Windows Application..
DialogResult result = MessageBox.Show("Do you want to save changes?", "Confirmation", messageBoxButtons.YesNoCancel);
if(result == DialogResult.Yes)
//...
else if (result == DialogResult.No)
//...
else
//...
But in aspx page..how can i write?please help me?
this might help you..
http://aspsnippets.com/Articles/Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx[^]
Go with jQuery plugins like jqueryui[^], easy to customize & browser compatible.
try this js function:-
function confirmBrSave() { var ans = confirm('Do you want to save this data?'); if (ans == true) { return true; } else { return false; } }
and call from code behind as like:-
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "overlay", "confirmBrSave();", True)
这篇关于MessageBox.Show()是否确认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!