ASP.NET中能彈出消息框嗎?
就是在應(yīng)用程序中使用MessageBox等彈出來(lái)的消息框!
不知道可以做到不,可以的話,該如何實(shí)現(xiàn)?
______________________________________________________________________________________________
答1:
Response.Write("<script language=‘javascript‘>alert(‘hello!‘)</script>");
______________________________________________________________________________________________
答2:
Javascript有許多內(nèi)建的方法來(lái)產(chǎn)生對(duì)話框,如:window.alert(), window.confirm(),window.prompt().等。 然而IE提供更多的方法支持對(duì)話框。如:showModalDialog() (IE 4+ 支持)
test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向?qū)υ捒騻鬟f數(shù)組
window.showModalDialog("test2.htm",mxh1)
// 向?qū)υ捒騻鬟fwindow對(duì)象
window.showModalDialog("test3.htm",mxh2)
</script>
test2.htm
====================
<script>
var a = window.dialogArguments
alert("您傳遞的參數(shù)為:" + a)
</script>
test3.htm
====================
<script>
var a = window.dialogArguments
alert("您傳遞的參數(shù)為window對(duì)象,名稱:" + a.name)
</script>
可以通過(guò)window.returnValue向打開(kāi)對(duì)話框的窗口返回信息,當(dāng)然也可以是對(duì)象。例如:
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>
常見(jiàn)問(wèn)題:
1,如何在模態(tài)對(duì)話框中進(jìn)行提交而不新開(kāi)窗口?
如果你 的 瀏覽器是IE5.5+,可以在對(duì)話框中使用帶name屬性的iframe,提交時(shí)可以制定target為該iframe的name。對(duì)于IE4+,你可以用高度為0的frame來(lái)作:例子,
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,可以通過(guò)
http://servername/virtualdirname/test.htm?name=mxh方式直接向?qū)υ捒騻鬟f參數(shù)嗎?
答案是不能。但在frame里是可以的。
______________________________________________________________________________________________
答3:
使用我的WebMessageBox控件,下載地址:
http://www.aspxcontrol.com______________________________________________________________________________________________
答4:
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
e.Item.Cells[7].Attributes["onclick"]="return confirm(‘確認(rèn)這條記錄刪除?‘);";
}
______________________________________________________________________________________________
答5:
if(MessageBox.Show( 要顯示的話,"標(biāo)題",MessageBoxButtons.YesNo,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification )==DialogResult.Yes)
{
//確認(rèn)處理后要執(zhí)行的代碼
}
______________________________________________________________________________________________
答6:
記得引用:
using System.Windows.Forms;
______________________________________________________________________________________________
答7:
ubc(做程序員“挺”好!)
在asp.net中能添加system.windows.forms這個(gè)命名空間嗎?
______________________________________________________________________________________________
答8:
解決方案(右邊)有個(gè)引用,右擊添加引用
System.Windows.Forms.dll
之后才可以使用
using System.Windows.Forms;
之后就可以按 ubc(做程序員“挺”好!) 說(shuō)的那樣使用MessageBox.Show啦
______________________________________________________________________________________________
答9:
JScript.Net同樣與javascript一樣的功能,還能實(shí)現(xiàn)如下:
window.showModelDialog("yourhtm.htm","center=yes,toolbar=no,status=no")且可以:
window.showModellessDialog(...同上)的功能,實(shí)現(xiàn)自定義對(duì)話框,
具體請(qǐng)參閱微軟的相關(guān)幫助。
______________________________________________________________________________________________
答10:
http://lucky_elove.www1.dotnetplayground.com/______________________________________________________________________________________________
答11:
http://lucky_elove.www1.dotnetplayground.com/ShowList.aspx?id=1