VS2008(C#)制作网页Tab标签切换方法(三)

VS2008(C#)制作网页Tab标签切换方法(三)——CS后台代码实现

 

前台HTML代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tab_CS.aspx.cs" Inherits="Tab_Tab_CS" %>

<!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>Tab后台CS程序实现</title>
    <style type="text/css">
        body
        {
            color: #000000;
            background-color: #ffffff;
            font-family: Tahoma, 宋体;
            font-size: 12px;
            margin: 0px;
            padding: 0px;
            text-align: center;
        }
        #TabButton1, #TabButton2, #TabButton3
        {
            margin-top: 20px;
            width: 60px;
        }
        .aaa
        {
            background-color: #E0E0E0;
        }
        .bbb
        {
            background-color: Gray;
            color: White;
        }
        #tab1, #tab2, #tab3
        {
            width: 188px;
            height: 100px;
            background-color: #E0E0E0;
            overflow: auto;
        }
        #tab2, #tab3
        {
            display: none;
        }
    </style>
</head>
<body>
    <form id="form1" runat="Server">
    <center>
        <div>
            <asp:Button ID="TabButton1" runat="server" CssClass="aaa" Text="查询" OnClick="TabButton1_Click" />
            <asp:Button ID="TabButton2" runat="server" CssClass="bbb" Text="新建" OnClick="TabButton2_Click" />
            <asp:Button ID="TabButton3" runat="server" CssClass="bbb" Text="修改" OnClick="TabButton3_Click" />
        </div>
        <div id="tab1" runat="Server">
            <asp:Label ID="Label1" runat="server" Text="111-查询"></asp:Label>
        </div>
        <div id="tab2" runat="Server">
            <asp:Label ID="Label2" runat="server" Text="222-新建"></asp:Label>
        </div>
        <div id="tab3" runat="Server">
            <asp:Label ID="Label3" runat="server" Text="333-修改"></asp:Label>
        </div>
    </center>
    </form>
</body>
</html>

 

后台CS代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Tab_Tab_CS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void TabButton1_Click(object sender, EventArgs e)
    {
        tab1.Style.Add("display", "block");
        tab2.Style.Add("display", "none");
        tab3.Style.Add("display", "none");
        TabButton1.CssClass = "aaa";
        TabButton2.CssClass = "bbb";
        TabButton3.CssClass = "bbb";
    }
    protected void TabButton2_Click(object sender, EventArgs e)
    {
        tab1.Style.Add("display", "none");
        tab2.Style.Add("display", "block");
        tab3.Style.Add("display", "none");
        TabButton1.CssClass = "bbb";
        TabButton2.CssClass = "aaa";
        TabButton3.CssClass = "bbb";
    }
    protected void TabButton3_Click(object sender, EventArgs e)
    {
        tab1.Style.Add("display", "none");
        tab2.Style.Add("display", "none");
        tab3.Style.Add("display", "block");
        TabButton1.CssClass = "bbb";
        TabButton2.CssClass = "bbb";
        TabButton3.CssClass = "aaa";
    }
}


具体代码如上,源代码下载: VS2008(C#)4种方法实现Tab标签灵活切换源码,测试成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值