模態窗口(showModalDialog)的專題討論(轉載)
小野 發表於 2006-6-1 15:30:34
討論內容
模態窗口的打開
模態窗口的關閉
模態窗口的參數傳遞
其他
模態窗口的打開
window.showModalDialog("DialogPage.aspx","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");
模態窗口的關閉
window.close();
模態窗口的參數傳遞
傳值
ParentPage.aspx:
window.showModalDialog("DialogPage.aspx?para1=aaa¶2=bbb");
DialogPage.aspx:
string str1=Request.QueryString["para1"].toString();
string str2=Request.QueryString["para2"].toString();
返回值
DialogPage.aspx:
window.returnValue="aaa";
ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");
其他
aspx頁面在showmodeldialog情況下爲什麼一提交就重新打開一個頁面?
showmodaldialog打開的頁面中在<head></head>之間加入一行:<base target="_self">
如果是在數據綁定的模式窗體中,還可以在DataGrid中創建一個模板列,再加入Html的按鈕,在按鈕中加入:OnClick="returnValue='<%#DataBind.Eval(Container.DataItem,"Name")%>';window.close()"
就可以實現在模式對話框中傳遞DataGrid的具體選中的行的相關值。