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

VS2008(C#)制作网页Tab标签切换方法(一)——AJAX控件

 

直接使用自定义的AJAX插件实现,具体的AJAX插件源文件和详细安装方法,

请详见本人上传的资源(AspAjax的安装与使用(内含安装文件和详细安装教程)-AJAX扩展控件,非常实用

按照里面的安装步骤一步一步安装完AJAX插件后,再设计如下代码就可(无需自己编写后台CS代码)

 

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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_AJAX</title>
    <style type="text/css">
        body
        {
            color: #000000;
            background-color: #ffffff;
            font-family: Tahoma, 宋体;
            font-size: 12px;
            margin: 0px;
            padding: 0px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <center>
        <div style="margin: 20px auto;">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="3" Height="180px"
                Width="400px">
                <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="文学">
                    <ContentTemplate>
                        111-文学
                    </ContentTemplate>
                </cc1:TabPanel>
                <cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="历史">
                    <ContentTemplate>
                        222-历史
                    </ContentTemplate>
                </cc1:TabPanel>
                <cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="科技">
                    <ContentTemplate>
                        333-科技
                    </ContentTemplate>
                </cc1:TabPanel>
                <cc1:TabPanel ID="TabPanel5" runat="server" HeaderText="军事">
                    <ContentTemplate>
                        444-军事
                    </ContentTemplate>
                </cc1:TabPanel>
            </cc1:TabContainer>
        </div>
    </center>
    </form>
</body>
</html>

 

 

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

posted @ 2010-01-29 20:31  程序员天下  阅读(299)  评论(0编辑  收藏  举报