母版页中弹出模式对话框,并获取返回值
来源:互联网 发布:数据分析在中国 编辑:程序博客网 时间:2024/06/07 13:00
Register.aspx页面是实现用户的注册,注册时需要选择用户所在单位,设计用弹出模式对话框(Org.aspx)里的TreeView选择用户所在单位。实现过程如下:
1、编写弹出模式对话框的脚本
//////////////////////////////////////////////////////////////////////////// 打开模式对话框// orgID:机构代码// orgName:机构名称// all:标识是否显示全部机构,为1时全部显示,为0时显示注册过的机构//////////////////////////////////////////////////////////////////////////function OpenOrgDlog(orgID,orgName, all,width,height) { var me; // 把父页面窗口对象当作参数传递到对话框中,以便对话框操纵父页自动刷新。 me = "Org.aspx?id="+orgID+"&name="+orgName+"&all="+all; // 显示对话框。 window.showModalDialog(me, window, 'dialogWidth=' + width + 'px;dialogHeight=' + height + 'px;help:no;status:no');}
2、在Register.aspx页面上添加按钮:LinkButton1,并在代码面中给按钮添加onclick属性:
string orgName = Request.Cookies["userInfo"]["orgName"].ToString(); string orgID = Request.Cookies["userInfo"]["orgID"].ToString(); LinkButton1.Attributes.Add("onclick", "javascript:OpenOrgDlog('" + orgID + "','" + orgName + "',1, 600,600)");
3、构造Org.aspx页面里的TreeView及其他元素,包括确认按钮,在aspx页面的<head>部分添加: <base target="_self" />
4、给Org.cs的确认按钮事件添加返回结果代码:
protected void btnOK_Click(object sender, EventArgs e) { if (txbOrgID.Text == "") { return; } string script = "var wind=window.dialogArguments; wind.document.getElementById('ctl00_ContentPlaceHolder1_txbOrgId').value='" + txbOrgID.Text + "';wind.document.getElementById('ctl00_ContentPlaceHolder1_HiddenField1').value='" + HiddenField1.Value + "';window.close()"; ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", script, true); }
由于Register.aspx采用母版页,并且有UpdatePanel,因此在btnOK_Click事件中的getElementById函数内用ctl00_ContentPlaceHolder1_XXX,ScriptManager.RegisterStartupScript用于在有UpdatePanel的页面中执行脚本语句。
- 母版页中弹出模式对话框,并获取返回值
- DataGrid中弹出模式对话框
- 网页中弹出模式对话框
- 在浏览器中弹出模式对话框
- Swing中弹出对话框
- c#中弹出对话框
- MFC中弹出对话框
- java中弹出对话框
- Swing中弹出对话框
- servlet中弹出对话框
- 简单的在Servlet中弹出对话框,确定后返回
- 工作线程中弹出对话框
- LinkButton中弹出确认对话框
- 在驱动中弹出对话框
- asp.net 中弹出对话框
- jsp中弹出对话框showModalDialog
- Android 中弹出对话框 代码
- Service中弹出AlertDialog对话框
- 面试信息获取_1
- An introduction to the SOLID principles of OO design
- GWTEXT之JSNI
- FPGA学习笔记6-Quartus II中的TCL脚本
- lsof[转载]
- 母版页中弹出模式对话框,并获取返回值
- USTCOJ 1281 Unhappy dots 快排模板
- 数据结构的排序
- FPGA学习笔记6-Quartus II中的TCL脚本(翻译)
- 他的统计学(转载)
- mac os 自带文件夹突然变为英文的解决办法
- http的header
- VB的一些小知识——重载Wndproc
- POJ2528 Mayor's posters