C#中如何弹出对话框???(100分)

Z

zjwyyh

Unregistered / Unconfirmed
GUEST, unregistred user!
C# asp.net 中MessageBox类不能用啦。那具有选择的对话框怎么弹出?
在aspx文档中嵌入js脚本
<script language=JavaScript>
var aaa=confrim("aaa","bbb")
if (aaa==true)
{
...
}

</script>
能行,
但我想在一个按钮的click事件中实现以上功能,该如何实现呢???
 
给你一个例子看看吧。
<%@ Page Language="C#" %>
<HTML>
<HEAD>
</HEAD>
<body>
<h3>ValidationSummary Sample</h3>
<p>
<form runat="server" ID="Form1">
<table cellpadding="10">
<tr>
<td>
<table bgcolor="#eeeeee" cellpadding="10">
<tr>
<td colspan="3">
<b>Credit Card Information</b>
</td>
</tr>
<tr>
<td align="right">
Card Type:
</td>
<td>
<asp:RadioButtonList id="RadioButtonList1" RepeatLayout="Flow" runat="server">
<asp:ListItem>MasterCard</asp:ListItem>
<asp:ListItem>Visa</asp:ListItem>
</asp:RadioButtonList>
</td>
<td align="middle" rowspan="1">
<asp:RequiredFieldValidator id="RequiredFieldValidator1" ControlToValidate="RadioButtonList1" ErrorMessage="Card Type. " Display="Static" InitialValue="" Width="100%" runat="server">
*
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Card Number:
</td>
<td>
<asp:TextBox id="TextBox1" runat="server" />
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" ControlToValidate="TextBox1" ErrorMessage="Card Number. " Display="Static" Width="100%" runat="server">
*
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button id="Button1" text="Validate" runat="server" />
</td>
<td></td>
</tr>
</table>
</td>
<td valign="top">
<table cellpadding="20">
<tr>
<td>
<asp:ValidationSummary id="valSum" DisplayMode="BulletList" ShowMessageBox="true" ShowSummary="false"
runat="server" HeaderText="You must enter a value in the following fields:" Font-Name="verdana" Font-Size="12" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</p>
</body>
</HTML>
 
MessageBox类在Asp.Net中是不能使用的。如果你想在点击Button后,弹出一个对话框,只能使用javascript脚本中的alert或vbscript脚本中的msgbox了。
 
说的也是,你在服务器端探出一个窗口有什么用呢?
 
使用javascript脚本中的alert或vbscript脚本中的msgbox就行了
 
同意楼上的!
 
楼上们说得对,不可能在服务器端谈出对话框
只能使用JavaScript中的alert等
 
我已在你的另外一个贴中回答:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2409500
 
button.Attributes["onclick"] = "JavaScript:return confirm('是否要做相应的动作?');";
 
MessageBox行吗?
 
MessageBox.Show("hahahaha,你說的是在c#中如何....");
 
carson_zdd兄:
其实在客户端弹出一个对话框道是不难,用你的方法,或用如下的方法都行:
Response.write("<Script Language=JavaScript>confirm(/"kkkkkkkkk/")</Script>");
问题是如何能知道用户选择了 "是" 还是 "否" 呢?从而决定是 执行下面的代码还是return.
能不能给个较详细的例子???
谢谢!!!
 
zjwyyh,使用下面这句:
button.Attributes["onclick"] = "JavaScript:return confirm('是否要做相应的动作?');";

其中button是你的按钮的名称,单击"否"推出单击事件的处理
使用Response.write()因为语句执行的顺序问题,是不能判断“是”“否”的操作的。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部