ASP.NET中能彈出消息框嗎?
就是在應(yīng)用程序中使用MessageBox等彈出來的消息框! 不知道可以做到不,可以的話,該如何實現(xiàn)? ______________________________________________________________________________________________ 答1: Response.Write("<script language=‘javascript‘>alert(‘hello!‘)</script>"); ______________________________________________________________________________________________ 答2: Javascript有許多內(nèi)建的方法來產(chǎn)生對話框,如: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") // 向?qū)υ捒騻鬟f數(shù)組 window.showModalDialog("test2.htm",mxh1) // 向?qū)υ捒騻鬟fwindow對象 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對象,名稱:" + 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,如何在模態(tài)對話框中進行提交而不新開窗口? 如果你 的 瀏覽器是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方式直接向?qū)υ捒騻鬟f參數(shù)嗎? 答案是不能。但在frame里是可以的。 ______________________________________________________________________________________________
答3: 使用我的WebMessageBox控件,下載地址: http://www. ______________________________________________________________________________________________ 答4: if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { e.Item.Cells[7].Attributes["onclick"]="return confirm(‘確認這條記錄刪除?‘);"; } ______________________________________________________________________________________________ 答5: if(MessageBox.Show( 要顯示的話,"標題",MessageBoxButtons.YesNo,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification )==DialogResult.Yes)
{ //確認處理后要執(zhí)行的代碼 } ______________________________________________________________________________________________ 答6: 記得引用: using System.Windows.Forms; ______________________________________________________________________________________________ 答7: ubc(做程序員“挺”好!) 在asp.net中能添加system.windows.forms這個命名空間嗎? ______________________________________________________________________________________________
答8: 解決方案(右邊)有個引用,右擊添加引用 System.Windows.Forms.dll 之后才可以使用
using System.Windows.Forms; 之后就可以按 ubc(做程序員“挺”好!) 說的那樣使用MessageBox.Show啦
______________________________________________________________________________________________ 答9: JScript.Net同樣與javascript一樣的功能,還能實現(xiàn)如下: window.showModelDialog("yourhtm.htm","center=yes,toolbar=no,status=no")且可以: window.showModellessDialog(...同上)的功能,實現(xiàn)自定義對話框, 具體請參閱微軟的相關(guān)幫助。 ______________________________________________________________________________________________ 答10: http://lucky_elove.www1./ ______________________________________________________________________________________________ 答11: http://lucky_elove.www1./ShowList.aspx?id=1 http://lucky_elove.www1./ShowDetail.aspx?id=9EEAFE96-3393-4228-A19C-C85A1456D104
______________________________________________________________________________________________ 答12: Response.Write("<script language=‘javascript‘>alert(‘hello!‘)</script>"); |
|
來自: ShangShujie > 《js》