关于一个子窗体向父窗体传值的问题
1 我的父窗体 是点击按钮打开一个窗体。
<asp:Button ID="btnChoseUnit" OnClientClick="javascript:OpenPopup();" runat="server"
Text="单位选择" />
<input type="hidden" id="txtUnitName" runat="server" />
<input type="hidden" id="txtUnitId" runat="server" />
<script type="text/javascript">
function OpenPopup() {
window.showModalDialog("TreeViewInfo.aspx", "List", "scrollbars=no,resizable=no,width=400,height=263");
}
function setValue(UnitName, UnitId) {
document.getElementById('txtUnitName').value = UnitName;
document.getElementById('txtUnitId').value = UnitId;
}
</script>
<input type="hidden" runat="server" id="txtUnitName" />
<input type="hidden" runat="server" id="txtUnitId" />
<div>
<asp:TreeView ID="TrView" Font-Bold="true" Font-Size="15px" runat="server" ImageSet="Contacts"
ShowCheckBoxes="All" OnTreeNodeCheckChanged="TrView_TreeNodeCheckChanged">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px"
ForeColor="#5555DD" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
</div>
<div>
<asp:Button ID="btnUnitAdd" runat="server" Text="确认选择" OnClick="btnUnitAdd_Click" />
</div>
</form>
StringBuilder strUname = new StringBuilder();
StringBuilder strUnitId = new StringBuilder();
//组织的名字
string UnitName = string.Empty;
//组织Id
string UnitId = string.Empty;
foreach (TreeNode item in TrView.CheckedNodes)
{
if (item.Checked)
{
strUname.AppendLine(item.Text + ";");
strUnitId.AppendLine(item.Value + ";");
}
}
// function valueClose() {
// var UnitName = docment.getElementById('txtUnitName').value;
// var UnitId = docment.getElementById('txtUnitId').value;
// opener.setValue(UnitName, UnitId)
// window.close();
//}
StringBuilder s = new StringBuilder();
s.Append("<script language=javascript>" + "\n");
s.Append("var UnitName = docment.getElementById('txtUnitName').value;");
s.Append("var UnitId = docment.getElementById('txtUnitId').value;");
s.Append("opener.setValue('" + strUname + "', '" + strUnitId + "')");
s.Append("window.close();" + "\n");
s.Append("</script>");
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
string csname = "ltype";
if (!cs.IsStartupScriptRegistered(cstype, csname))
cs.RegisterStartupScript(cstype, csname, s.ToString());