asp.net我们经常在主页中要浏览分类信息,在C/S模式下,经常采用Tab分页的方式来做,然后将不同的信息放到不同的Tab页中,然后可以点击页签去查看不同页面中的内容。我们可以用网页的IFRAME来实行这个功能,先建立一个主WebForm1,在上面放两个按钮来模拟页签(今后也可以用Photoshop来制作更精美的页签),然后再建立两个子Form,WebForm2,WebForm3,当按钮被按下的时候来切换IFRAME的src属性去显示不同的子页面。具体代码如下:
WebForm1.aspx
<% Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="iframetest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<STYLE>.aaa {
BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #ffcc33; BORDER-BOTTOM-STYLE: none
}
.bbb {
BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #99ffcc; BORDER-BOTTOM-STYLE: none
}
</STYLE>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:button id="Button1" 101; LEFT: 16px; POSITION: absolute; TOP: 24px" runat="server"
Text="Button" CssClass="aaa"></asp:button>
<asp:Button id="Button2" 102; LEFT: 72px; POSITION: absolute; TOP: 24px" runat="server"
Text="Button" CssClass="bbb"></asp:Button>
<iframe id="IFRAME1" 0px solid; BORDER-TOP: 0px solid; Z-INDEX: 103; LEFT: 16px; BORDER-LEFT: 0px solid; WIDTH: 648px; BORDER-BOTTOM: 0px solid; POSITION: absolute; TOP: 40px; HEIGHT: 288px"
runat="server"></iframe>
</form>
</body>
</HTML>
WebForm1.aspx.cs
.
.
.
private void Button1_Click(object sender, System.EventArgs e)
{
IFRAME1.Attributes.Add("src","Webform2.aspx");
}
private void Button2_Click(object sender, System.EventArgs e)
{
IFRAME1.Attributes.Add("src","Webform3.aspx");
}
[ASP.NET]制作一个简单的多页Tab功能
80酷酷网 80kuku.com