result = MessageBox.Show(this, message, caption, buttons,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign); if(result == DialogResult.Yes)
{ // Closes the parent form. this.Close(); }
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign); if(result == DialogResult.Yes)
{ // Closes the parent form. this.Close(); }
Button.DialogResult 属性和 Form.ShowDialog 方法使用此枚举。成员
成员名称 说明
Abort
受 .NET Framework 精简版的支持。
对话框的返回值是 Abort(通常由标签为“中止”的按钮发送)。
Cancel
受 .NET Framework 精简版的支持。
对话框的返回值是 Cancel(通常由标签为“取消”的按钮发送)。
Ignore
受 .NET Framework 精简版的支持。
对话框的返回值是 Ignore(通常由标签为“忽略”的按钮发送)。
No
受 .NET Framework 精简版的支持。
对话框的返回值是 No(通常由标签为“否”的按钮发送)。
None
受 .NET Framework 精简版的支持。
从对话框返回了 Nothing。这表明有模式对话框继续运行。
OK
受 .NET Framework 精简版的支持。
对话框的返回值是 OK(通常由标签为“确定”的按钮发送)。
Retry
受 .NET Framework 精简版的支持。
对话框的返回值是 Retry(通常由标签为“重试”的按钮发送)。
Yes
受 .NET Framework 精简版的支持。
对话框的返回值是 Yes(通常由标签为“是”的按钮发送)。
result = MessageBox.Show("确定要删除此项目?","About",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);if(result == DialogResult.Yes)
提示错误:类型或命名空间名称“Windows”在类或命名空间“System”中不存在(是否缺少程序集引用?) 为什么错呀,刚学C#所以有些不懂,请教各位大虾们要想在asp.net里实现messagebox该怎么写?? 在线等...
在asp.net里面可以用脚本。
<script language=jscript>
function mm_click()
{
if(confirm("确定要....?"))
{
........
}
else
{
......
}
}
</script>在页面上:
<input type=button value="button1" onclick='mm_click()'>if是ASP.Net控件,在后台Load函数里面加上:如:ASP:buttonButton1.Attribts["onClick"]="return mm_click()";在mm_click()里如果返回true则提交到服务器,返回false则不提交到服务器。
this.Button1.Attributes.Add("onclick", "return confirm('您真的要跳转?')");