asp.net实现简单Tab页
来源:互联网 发布:瑞士军刀能过安检知乎 编辑:程序博客网 时间:2024/05/22 02:05
在C/S模式下,经常采用Tab分页的方式来做,然后将不同的信息放到不同的Tab页中,然后可以点击页签去查看不同页面中的内容。在Web开发中,也需要用到这样的Tab页,实现的方式有很多种,现在来介绍一种简单的Tab页的实现方式:用iframe来实现。
具体步骤是:先建立一个主TabForm.aspx,在上面放两个按钮来模拟页签(今后也可以用Photoshop来制作更精美的图片来作Tab标签),然后再建立两个子Form,WebForm1,WebForm2,当按钮被按下的时候来切换IFRAME的src属性去显示不同的子页面。
具体步骤是:先建立一个主TabForm.aspx,在上面放两个按钮来模拟页签(今后也可以用Photoshop来制作更精美的图片来作Tab标签),然后再建立两个子Form,WebForm1,WebForm2,当按钮被按下的时候来切换IFRAME的src属性去显示不同的子页面。
具体代码如下:
TabForm.aspx
<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="TabForm.aspx.cs" Inherits="TabForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<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>
<form id="form1" runat="server">
<div>
<asp:button id="Button1" style="Z-INDEX: 101; POSITION: absolute; TOP: 24px; width:100px;" runat="server"
Text="WebFrom1Tab" CssClass="aaa" OnClick="Button1_Click"></asp:button>
<asp:Button id="Button2" style="Z-INDEX: 102; POSITION: absolute; TOP: 25px; left: 111px;width:100px;" runat="server"
Text="WebFrom2Tab" CssClass="bbb" OnClick="Button2_Click"></asp:Button>
<iframe id="IFRAME1" style="BORDER-RIGHT: 0px solid; BORDER-TOP: 0px solid; Z-INDEX: 103;
LEFT: 11px; BORDER-LEFT: 0px solid; WIDTH: 924px; BORDER-BOTTOM: 0px solid; POSITION: absolute; TOP: 47px; HEIGHT: 555px"
runat="server"></iframe>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<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>
<form id="form1" runat="server">
<div>
<asp:button id="Button1" style="Z-INDEX: 101; POSITION: absolute; TOP: 24px; width:100px;" runat="server"
Text="WebFrom1Tab" CssClass="aaa" OnClick="Button1_Click"></asp:button>
<asp:Button id="Button2" style="Z-INDEX: 102; POSITION: absolute; TOP: 25px; left: 111px;width:100px;" runat="server"
Text="WebFrom2Tab" CssClass="bbb" OnClick="Button2_Click"></asp:Button>
<iframe id="IFRAME1" style="BORDER-RIGHT: 0px solid; BORDER-TOP: 0px solid; Z-INDEX: 103;
LEFT: 11px; BORDER-LEFT: 0px solid; WIDTH: 924px; BORDER-BOTTOM: 0px solid; POSITION: absolute; TOP: 47px; HEIGHT: 555px"
runat="server"></iframe>
</div>
</form>
</body>
</html>
TabForm.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class TabForm : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void Button1_Click(object sender, EventArgs e)
...{
IFRAME1.Attributes.Add("src", "Webform1.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
...{
IFRAME1.Attributes.Add("src", "Webform2.aspx");
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class TabForm : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void Button1_Click(object sender, EventArgs e)
...{
IFRAME1.Attributes.Add("src", "Webform1.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
...{
IFRAME1.Attributes.Add("src", "Webform2.aspx");
}
}
- asp.net实现简单Tab页
- asp.net实现简单Tab页
- asp.net实现简单Tab页
- asp.net 实现回车替代Tab
- asp.net 实现回车替代Tab
- asp.net tab
- 简单实现asp.net进度条
- WEB页面简单实现TAB页
- jquery tab页切换简单实现
- asp.net 多页Tab功能
- ASP.NET实现简单的验证码
- ASP.NET实现简单的文字水印
- asp.net简单实现页面换肤
- ASP.NET简单实现服务端图片缓存
- ASP.NET 实现简单的权限控制
- asp.net调用存储过程简单实现
- ASP.NET中实现简单文件上传
- asp.net 实现一个简单CAS Server
- hibernate结合mysql产生hbm映射文件和POJO(只适应与hibernate2.x版本)
- 插入U盘托盘区不显示已连接USB设备图标,怎么安全删除U盘
- Oracle应用专题之:分析函数3(Top/Bottom N、First/Last、NTile)
- 新网域名注册空间代理
- JAVA 基础 - 构造函数
- asp.net实现简单Tab页
- ini配置文件读写
- 【MM】采购退货的处理办法
- 主动示弱可赢得人心
- 解决Windows 程序界面闪烁问题的一些经验
- MBR
- 2个SQL语句的区别(续)
- 从bootm看u-boot引导内核的过程
- 累了看一下啊 笑话