您的位置:首页 > 编程语言 > C#

VS.NET(C#)-4.3_MultiView和View控件应用案例一

2018-02-23 20:46 603 查看
MultiView和View控件应用案例一MultiView和View搭配实现选项卡效果,切换Tab按钮是用两个Button(ImageButton实现效果更好)。关联到一个事件处理程序。
重点用法:ActiveViewIndex的值来选择当前要显示的view。
UI设计视图



UI代码视图
<%@ PageLanguage="C#"AutoEventWireup="true"CodeFile="MultiViewDemo01.aspx.cs"
    Inherits="MultiViewDemo01" %>
<!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>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="btn1" runat="server" Text="请假规则" OnClick="btn1_Click"/>
            <asp:Button ID="btn2" runat="server" Text="签核流程" OnClick="btn2_Click"/>
            <br />
            <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
                <asp:View ID="View1" runat="server">
                    <asp:Label ID="lbl01" runat="server" Text="Label"></asp:Label>
                </asp:View>
                <asp:View ID="View2" runat="server">
                    <asp:Label ID="lbl02" runat="server" Text="Label"></asp:Label>
                </asp:View>
            </asp:MultiView>
        </div>
    </form>
</body>
</html>
CS后台视图
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
public partial class MultiViewDemo01 : System.Web.UI.Page
{
    protected void Page_Load(objectsender, EventArgs e)
    {
       lbl01.Text = "请假说明:首先顶格写称谓,即向谁请假,注意应加上其职务,";
       lbl02.Text = "签核流程:按照组织架构原则从课级开始向上签核";
    }
    protected void btn1_Click(objectsender, EventArgs e)
    {
        btn_Info(sender, e);
        //MultiView1.ActiveViewIndex= 0;
    }
    protected void btn2_Click(objectsender, EventArgs e)
    {
        btn_Info(sender, e);
        //MultiView1.ActiveViewIndex= 1;
    }
    protected void btn_Info(objectsender, EventArgs e)
    {
        Buttonb = (Button)sender;
        if(b.ID== "btn1")
        {
            MultiView1.SetActiveView(View1);
        }
        else
        {
            MultiView1.SetActiveView(View2);
        }
    }
}
 
UI运行时图

 

 
 
 
 
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: