(精)在ASP.NET中使用IFRAME+DIV,可以实现在同一页面使用弹出(模态)窗口
2007-12-19 10:44
961 查看
我们经常要在程序的人机交互中用到弹出(模态)窗口,但在B/S开发中,这一点就非常不容易了, 虽然我们可以用window.showModalDialog,或者 window.open 这类型的脚本函数实现,但是,非常不好用,一方面涉及回传值,另一方面不能够很好的实现父页面与子页面的交互,一般只能通过在脚本中实现<base target="_self">,方可交互,而且使用这种方式,会产生多个页面,对用户操作不友好.
基于上述情况, 我尝试在初始页面中嵌入一个IFRAME+DIV的方式,来显示可能会用到的弹出(模态)窗口, 另外特别注意,将IFRAME+DIV设置到能覆盖整个页面项,为了弹出(模态)窗口隐藏原页面内容.还有,当需要关闭弹出(模态)窗口
时,只需要将DIV状态改变,即可.
选择IFRAME+DIV的方式,主要是:
1.DIV不能隐藏原页面的控件内容,而IFRAME可以。
2.IFRAME可以整合控件,而DIV做的不好。
详细部分请参考代码:
WebForm1.aspx 前台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>WebForm1</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="CODE_LANGUAGE" Content="C#">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_defaultClientScript" content="JavaScript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function ShowLayer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.MyFormLayer.style.display='';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function SetURL(url)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.IFRAME1.src=url;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body MS_POSITIONING="GridLayout">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<form id="Form1" method="post" runat="server">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<FONT face="宋体">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox2" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 136px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button4" style="Z-INDEX: 107; LEFT: 224px; POSITION: absolute; TOP: 168px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择3"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox3" style="Z-INDEX: 106; LEFT: 64px; POSITION: absolute; TOP: 168px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 224px; POSITION: absolute; TOP: 136px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择2"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button3" style="Z-INDEX: 105; LEFT: 224px; POSITION: absolute; TOP: 136px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择2"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</FONT>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" style="Z-INDEX: 100; LEFT: 64px; POSITION: absolute; TOP: 104px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 224px; POSITION: absolute; TOP: 104px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择1"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="MyFormLayer" style="DISPLAY: none;Z-INDEX: 9999;LEFT: 8px;WIDTH: 328px;POSITION: absolute;TOP: 8px;HEIGHT: 256px">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<iframe scrolling="no" frameborder="0" width="100%" height="100%" id="IFRAME1" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
style="WIDTH: 87.29%; HEIGHT: 91.04%"></iframe>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</form>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm1.aspx 后台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebForm1 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebForm1 : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.HtmlControls.HtmlGenericControl IFRAME1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!IsPostBack)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static void CreateScript(System.Web.UI.Page mypage,string strScript,string ID)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string strscript="<script language='javascript'>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strscript += strScript;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strscript += "</script>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!mypage.IsStartupScriptRegistered(ID))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
mypage.RegisterStartupScript(ID, strscript);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Button2_Click(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IFRAME1.Attributes.Add("src","WebForm2.aspx?NAME='中国'");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CreateScript(Page,"ShowLayer();","SHOW");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button4.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button3.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button1.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm2.aspx 前台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm2" %>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>WebForm2</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="CODE_LANGUAGE" Content="C#">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_defaultClientScript" content="JavaScript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function hide()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
parent.MyFormLayer.style.display = "none";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body MS_POSITIONING="GridLayout">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<form id="Form2" method="post" runat="server">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#6887bb" height="100%"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
id="table1" style="BORDER-TOP-STYLE: outset; BORDER-RIGHT-STYLE: outset; BORDER-LEFT-STYLE: outset; BORDER-BOTTOM-STYLE: outset">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p align="center"><font color="#ffffff">选择弹出(模态)窗口的值</font></p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p align="center"><input type="button" onclick="hide()" style="WIDTH: 80px" value="点击关闭"> </p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</table>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</form>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm2.aspx 后台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebForm2 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebForm2 : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
基于上述情况, 我尝试在初始页面中嵌入一个IFRAME+DIV的方式,来显示可能会用到的弹出(模态)窗口, 另外特别注意,将IFRAME+DIV设置到能覆盖整个页面项,为了弹出(模态)窗口隐藏原页面内容.还有,当需要关闭弹出(模态)窗口
时,只需要将DIV状态改变,即可.
选择IFRAME+DIV的方式,主要是:
1.DIV不能隐藏原页面的控件内容,而IFRAME可以。
2.IFRAME可以整合控件,而DIV做的不好。
详细部分请参考代码:
WebForm1.aspx 前台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>WebForm1</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="CODE_LANGUAGE" Content="C#">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_defaultClientScript" content="JavaScript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function ShowLayer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.MyFormLayer.style.display='';
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function SetURL(url)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.IFRAME1.src=url;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body MS_POSITIONING="GridLayout">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<form id="Form1" method="post" runat="server">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<FONT face="宋体">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox2" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 136px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button4" style="Z-INDEX: 107; LEFT: 224px; POSITION: absolute; TOP: 168px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择3"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox3" style="Z-INDEX: 106; LEFT: 64px; POSITION: absolute; TOP: 168px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 224px; POSITION: absolute; TOP: 136px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择2"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button3" style="Z-INDEX: 105; LEFT: 224px; POSITION: absolute; TOP: 136px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择2"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<br>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</FONT>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" style="Z-INDEX: 100; LEFT: 64px; POSITION: absolute; TOP: 104px" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 224px; POSITION: absolute; TOP: 104px" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Text="选择1"></asp:Button>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="MyFormLayer" style="DISPLAY: none;Z-INDEX: 9999;LEFT: 8px;WIDTH: 328px;POSITION: absolute;TOP: 8px;HEIGHT: 256px">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<iframe scrolling="no" frameborder="0" width="100%" height="100%" id="IFRAME1" runat="server"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
style="WIDTH: 87.29%; HEIGHT: 91.04%"></iframe>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</form>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm1.aspx 后台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebForm1 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebForm1 : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.HtmlControls.HtmlGenericControl IFRAME1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.Button Button3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!IsPostBack)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static void CreateScript(System.Web.UI.Page mypage,string strScript,string ID)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string strscript="<script language='javascript'>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strscript += strScript;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strscript += "</script>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!mypage.IsStartupScriptRegistered(ID))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
mypage.RegisterStartupScript(ID, strscript);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Button2_Click(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IFRAME1.Attributes.Add("src","WebForm2.aspx?NAME='中国'");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CreateScript(Page,"ShowLayer();","SHOW");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button4.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button3.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Button1.Click += new System.EventHandler(this.Button2_Click);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm2.aspx 前台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="WebApplication2.WebForm2" %>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>WebForm2</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="CODE_LANGUAGE" Content="C#">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_defaultClientScript" content="JavaScript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function hide()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
parent.MyFormLayer.style.display = "none";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HEAD>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body MS_POSITIONING="GridLayout">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<form id="Form2" method="post" runat="server">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#6887bb" height="100%"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
id="table1" style="BORDER-TOP-STYLE: outset; BORDER-RIGHT-STYLE: outset; BORDER-LEFT-STYLE: outset; BORDER-BOTTOM-STYLE: outset">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p align="center"><font color="#ffffff">选择弹出(模态)窗口的值</font></p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p align="center"><input type="button" onclick="hide()" style="WIDTH: 80px" value="点击关闭"> </p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</td>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</tr>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</table>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</form>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</HTML>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WebForm2.aspx 后台页面:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebForm2 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebForm2 : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 在ASP.NET中使用IFRAME+DIV,可以实现在同一页面使用弹出(模态)窗口
- 如何在ASP.NET中使用div弹出窗口
- ASP.NET弹出窗口Div实现
- DIV+IFrame实现页面弹出窗口
- ASP.NET下实现真正的模态窗口
- ASP.NET Ajax实现弹出提示框,页面变灰不可点击
- ASP.NET中在本页面弹出窗口,主页面变成灰色
- ASP.NET实现自适应图片大小的弹出窗口(窗口可任意编辑)
- ASP.NET Ajax实现弹出提示框,页面变灰不可点击
- ASP.NET实现自适应图片大小的弹出窗口
- Asp.Net 使用模板页也可以给每个页面加CSS文件链接
- asp.net 2.0 ajax中实现弹出窗口报警提示
- ASP.NET MVC中使用OutputCache实现服务器端页面级缓存注意问题
- asp.net 弹出窗口 单击确定和取消跳转到指定页面
- asp.net 中使用iframe动态加载页面
- 使用window.showModalDialog弹出的模态窗口中打印功能的实现
- asp.net 中使用iframe动态加载页面
- ASP.NET实现自适应图片大小的弹出窗口(窗口可任意编辑)
- ASP.NET之使用Ajax实现页面异步刷新(无需刷新整个页面)
- ASP.NET使用弹出窗口(对话框)的体会