ASP.NET中能弹出消息框吗? Response.Write("<script language='javascript'>alert('hello!')</script>"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Javascript有许多内建的方法来产生对话框,如:window.alert(), window.confirm(),window.prompt().等。 然而IE提供更多的方法支持对话框。如:showModalDialog() (IE 4+ 支持) test1.htm==================== <script> var mxh1 = new Array("mxh","net_lover","孟子E章") var mxh2 = window.open("about:blank","window_mxh") // 向对话框传递数组 window.showModalDialog("test2.htm",mxh1) // 向对话框传递window对象 window.showModalDialog("test3.htm",mxh2) </script> test2.htm==================== <script> var a = window.dialogArguments alert("您传递的参数为:" + a) </script> test3.htm==================== <script> var a = window.dialogArguments alert("您传递的参数为window对象,名称:" + a.name) </script> 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm=================== <script> var a = window.showModalDialog("test5.htm") for(i=0;i<a.length;i++) alert(a[i]) </script> test5.htm=================== <script> function sendTo() { var a=new Array("a","b") window.returnValue = a window.close() } </script> <body> <form> <input value="返回" type=button onclick="sendTo()"> </form> 常见问题: 1,如何在模态对话框中进行提交而不新开窗口? 如果你 的 浏览器是IE5.5+,可以在对话框中使用带name属性的iframe,提交时可以制定target为该iframe的name。对于IE4+,你可以用高度为0的frame来作:例子, test6.htm =================== <script> window.showModalDialog("test7.htm") </script> test7.htm =================== if(window.location.search) alert(window.location.search) <frameset rows="0,*"> <frame src="about:blank"> <frame src="test8.htm"> </frameset> test8.htm =================== <form target="_self" method="get"> <input name=txt value="test"> <input type=submit> </form> <script> if(window.location.search) alert(window.location.search) </script> 2,可以通过http://servername/virtualdirname/test.htm?name=mxh方式直接向对话框传递参数吗? 答案是不能。但在frame里是可以的。 使用我的WebMessageBox控件,下载地址:http://www.aspxcontrol.com if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { e.Item.Cells[7].Attributes["onclick"]="return confirm('确认这条记录删除?');"; } if(MessageBox.Show( 要显示的话,"标题",MessageBoxButtons.YesNo,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification )==DialogResult.Yes){//确认处理后要执行的代码} 记得引用:using System.Windows.Forms; ubc(做程序员“挺”好!) 在asp.net中能添加system.windows.forms这个命名空间吗? 解决方案(右边)有个引用,右击添加引用System.Windows.Forms.dll之后才可以使用using System.Windows.Forms;之后就可以按 ubc(做程序员“挺”好!) 说的那样使用MessageBox.Show啦 JScript.Net同样与javascript一样的功能,还能实现如下:window.showModelDialog("yourhtm.htm","center=yes,toolbar=no,status=no")且可以:window.showModellessDialog(...同上)的功能,实现自定义对话框,具体请参阅微软的相关帮助。 http://lucky_elove.www1.dotnetplayground.com/ http://lucky_elove.www1.dotnetplayground.com/ShowList.aspx?id=1http://lucky_elove.www1.dotnetplayground.com/ShowDetail.aspx?id=9EEAFE96-3393-4228-A19C-C85A1456D104 Response.Write("<script language='javascript'>alert('hello!')</script>"); 调查一下:写个小小的程序,是新建一个什么样的解决方案好?进者皆有分 把源代码直接部署到IIS里会有什么问题? 谁有好的日期控件 删除数据问题(新手) 超链接打开位置,在线等 谁有用asp.net开发的图书管理系统啊,给小妹发个啊,做毕业设计中啊!! VS.Net用户的技术交流群号10370288 关于ajax.net发送数据的问题?? js数字转换为大写(包含负数) 如何查看_viewstate的明文 关于treeview的使用! 再问一次有关水晶报表的问题,up有分!
test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
// 向对话框传递window对象
window.showModalDialog("test3.htm",mxh2)
</script> test2.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为:" + a)
</script> test3.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为window对象,名称:" + a.name)
</script> 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm
===================
<script>
var a = window.showModalDialog("test5.htm")
for(i=0;i<a.length;i++) alert(a[i])
</script> test5.htm
===================
<script>
function sendTo()
{
var a=new Array("a","b")
window.returnValue = a
window.close()
}
</script>
<body>
<form>
<input value="返回" type=button onclick="sendTo()">
</form> 常见问题:
1,如何在模态对话框中进行提交而不新开窗口?
如果你 的 浏览器是IE5.5+,可以在对话框中使用带name属性的iframe,提交时可以制定target为该iframe的name。对于IE4+,你可以用高度为0的frame来作:例子, test6.htm
===================
<script>
window.showModalDialog("test7.htm")
</script> test7.htm
===================
if(window.location.search) alert(window.location.search)
<frameset rows="0,*">
<frame src="about:blank">
<frame src="test8.htm">
</frameset> test8.htm
===================
<form target="_self" method="get">
<input name=txt value="test">
<input type=submit>
</form>
<script>
if(window.location.search) alert(window.location.search)
</script>
2,可以通过http://servername/virtualdirname/test.htm?name=mxh方式直接向对话框传递参数吗?
答案是不能。但在frame里是可以的。
http://www.aspxcontrol.com
{
e.Item.Cells[7].Attributes["onclick"]="return confirm('确认这条记录删除?');";
}
if(MessageBox.Show( 要显示的话,"标题",MessageBoxButtons.YesNo,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification )==DialogResult.Yes)
{
//确认处理后要执行的代码
}
using System.Windows.Forms;
在asp.net中能添加system.windows.forms这个命名空间吗?
System.Windows.Forms.dll之后才可以使用
using System.Windows.Forms;之后就可以按 ubc(做程序员“挺”好!) 说的那样使用MessageBox.Show啦
window.showModelDialog("yourhtm.htm","center=yes,toolbar=no,status=no")且可以:
window.showModellessDialog(...同上)的功能,实现自定义对话框,
具体请参阅微软的相关帮助。