【发布时间】:2013-02-15 06:48:12
【问题描述】:
我使用 showModalDialog 函数打开弹出窗口,即 ASP.NET 页面。在下拉列表中选择一些选项后,我填充 window.ReturnValue 并按 OK 按钮。模态弹出窗口关闭,但我不知道如何将返回值传递给后面的 C# 代码以继续进行。
代码如下:
打开弹窗:
function ClientItemClicked(sender, eventArgs)
{
if (eventArgs.get_item().get_value() == "excel")
{
var retVal = window.showModalDialog("ExportToExcelChoice.aspx", null, "dialogWidth: 400; dialogHeight: 200; center: yes; resizable: no;");
}
}
关闭弹出窗口:
function ReturnValue() {
var choice = document.getElementById("DropDownList1").value;
if ((window.opener != null) && (!window.opener.closed)) {
window.ReturnValue = choice;
var result = window.ReturnValue;
}
window.close();
}
我使用火狐。
【问题讨论】:
-
也许把它写在一个隐藏的字段中,然后从那里读取?
-
我试过了,但我不知道如何访问隐藏字段,因为隐藏字段放在用户控件内,用户控件在占位符内,占位符在内容页面内,内容页面在母版页内。我从用户控件内部打开模式窗口。你知道怎么做吗?