Multiview和View控件

    MultiView View 控件和制作出选项卡的效果,MultiView 控件是一组 View 控件的容器。使用它可定义一组 View 控件,其中每个 View 控件都包含子控件。
    如果要切换视图,可以使用控件的ID或者View控件的索引值。在 MultiView 控件中,一次只能将一个 View 控件定义为活动视图。如果某个 View 控件定义为活动视图,它所包含的子控件则会呈现到客户端。可以使用 ActiveViewIndex 属性或SetActiveView 方法定义活动视图。如果 ActiveViewIndex 属性为空,则 MultiView 控件不向客户端呈现任何内容。如果活动视图设置为MultiView 控件中不存在的 View,则会在运行时引发 ArgumentOutOfRangeException
    一些常用的属性、方法:
    ActiveViewIndex属性:用于获取或设置当前被激活显示的View控件的索引值。默认值为-1,表示没有View控件被激活。
    SetActiveView方法:用于激活显示特定的View控件。
    4个静态只读字段:若要允许用户在 MultiView 控件中的 View 控件之间进行导航,可将 LinkButtonButton 控件添加到每个 View 控件。若要利用 MultiView 控件对当前活动 View 进行自动更新,请将按钮或链接按钮的 CommandName 属性设置为与所需导航行为对应的命令名字段的值,这些命令名字段如下:PreviousViewCommandNameNextViewCommandNameSwitchViewByIDCommandNameSwitchViewByIndexCommandName
    ActiveViewChanged事件:当视图切换时被激发。

应用示例:

ContractedBlock.gif ExpandedBlockStart.gif Default.aspx
None.gif<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
None.gif
None.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
None.gif
<html xmlns="http://www.w3.org/1999/xhtml">
None.gif
<head runat="server">
None.gif    
<title>示例8-5</title>
None.gif    
<link id="InstanceStyle" href="StyleSheet.css" type="text/css" rel="stylesheet" />
None.gif
</head>
None.gif
<body>
None.gif    
<form id="Form1" runat="server">
None.gif        
<div>
None.gif            
<fieldset style="width: 400px">
None.gif                
<legend class="mainTitle">MultiView和View控件典型应用</legend>
None.gif                
<br />
None.gif                
<table id="Table1" height="95%" cellspacing="0" cellpadding="0" width="100%" border="0">
None.gif                    
<tr>
None.gif                        
<td>
None.gif                            
<table id="TopTable" runat="server" cellspacing="0" cellpadding="0" width="100%"
None.gif                                border
="0">
None.gif                                
<tr style="height: 22px">
None.gif                                    
<td class="SelectedTopBorder" id="Cell1" align="center" width="60">
None.gif                                        
<asp:LinkButton ID="LBView1" runat="server" CssClass="TopTitle" OnClick="LBView1_Click">常规</asp:LinkButton>
None.gif                                    
</td>
None.gif                                    
<td class="SepBorder" width="2px">
None.gif                                        
&nbsp;</td>
None.gif                                    
<td class="TopBorder" id="Cell2" align="center" width="60">
None.gif                                        
<asp:LinkButton ID="LBView2" runat="server" CssClass="TopTitle" OnClick="LBView2_Click">硬件</asp:LinkButton>
None.gif                                    
</td>
None.gif                                    
<td class="SepBorder" width="2px">
None.gif                                        
&nbsp;</td>
None.gif                                    
<td class="TopBorder" id="Cell3" align="center" width="60">
None.gif                                        
<asp:LinkButton ID="LBView3" runat="server" CssClass="TopTitle" OnClick="LBView3_Click">高级</asp:LinkButton>
None.gif                                    
</td>
None.gif                                    
<td class="SepBorder">
None.gif                                        
&nbsp;</td>
None.gif                                
</tr>
None.gif                            
</table>
None.gif                        
</td>
None.gif                    
</tr>
None.gif                    
<tr>
None.gif                        
<td>
None.gif                            
<table class="ContentBorder" cellspacing="0" cellpadding="0">
None.gif                                
<tr>
None.gif                                    
<td valign="top">
None.gif                                        
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
None.gif                                            
<asp:View ID="View1" runat="server">
None.gif                                                
<img src="images/tab0.jpg" />
None.gif                                            
</asp:View>
None.gif                                            
<asp:View ID="View2" runat="server">
None.gif                                                
<img src="images/tab2.jpg" />
None.gif                                            
</asp:View>
None.gif                                            
<asp:View ID="View3" runat="server">
None.gif                                                
<img src="images/tab3.jpg" />
None.gif                                            
</asp:View>
None.gif                                        
</asp:MultiView>
None.gif                                    
</td>
None.gif                                
</tr>
None.gif                            
</table>
None.gif                        
</td>
None.gif                    
</tr>
None.gif                
</table>
None.gif            
</fieldset>
None.gif        
</div>
None.gif    
</form>
None.gif
</body>
None.gif
</html>

ContractedBlock.gif ExpandedBlockStart.gif Default.aspx.cs
None.gifusing System;
None.gif
using System.Data;
None.gif
using System.Configuration;
None.gif
using System.Web;
None.gif
using System.Web.Security;
None.gif
using System.Web.UI;
None.gif
using System.Web.UI.WebControls;
None.gif
using System.Web.UI.WebControls.WebParts;
None.gif
using System.Web.UI.HtmlControls;
None.gif
None.gif
public partial class _Default : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{}
InBlock.gif    
InBlock.gif    
protected void LBView1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        MultiView1.ActiveViewIndex 
= 0;        
InBlock.gif        Cell1.Attributes[
"class"= "SelectedTopBorder";
InBlock.gif        Cell2.Attributes[
"class"= "TopBorder";
InBlock.gif        Cell3.Attributes[
"class"= "TopBorder";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
protected void LBView2_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        MultiView1.ActiveViewIndex 
= 1;
InBlock.gif        Cell1.Attributes[
"class"= "TopBorder";
InBlock.gif        Cell2.Attributes[
"class"= "SelectedTopBorder";
InBlock.gif        Cell3.Attributes[
"class"= "TopBorder";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
protected void LBView3_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        MultiView1.ActiveViewIndex 
= 2;
InBlock.gif        Cell1.Attributes[
"class"= "TopBorder";
InBlock.gif        Cell2.Attributes[
"class"= "TopBorder";
InBlock.gif        Cell3.Attributes[
"class"= "SelectedTopBorder";
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

ContractedBlock.gif ExpandedBlockStart.gif StyleSheet.css
None.gifbody
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    font
-size: 11pt;
InBlock.gif    font
-family: 宋体;
ExpandedBlockEnd.gif}

None.gif.mainTitle
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    font
-size: 12pt;
InBlock.gif    font
-weight: bold;
InBlock.gif    font
-family: 宋体;
ExpandedBlockEnd.gif}

None.gif.commonText
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    font
-size: 11pt;
InBlock.gif    font
-family: 宋体;
ExpandedBlockEnd.gif}

None.gif.littleMainTitle
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    font
-size: 10pt;
InBlock.gif    font
-weight: bold;
InBlock.gif    font
-family: 宋体;
ExpandedBlockEnd.gif}

None.gif.TopTitle
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border: 0px;
InBlock.gif    font
-size: 10pt;
InBlock.gif    font
-weight: bold;
InBlock.gif    text
-decoration: none;
InBlock.gif    color: Black;
InBlock.gif    display: inline
-block;
InBlock.gif    width: 
100%;    
ExpandedBlockEnd.gif}

None.gif.SelectedTopTitle
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border: 0px;
InBlock.gif    font
-size: 10pt;
InBlock.gif    text
-decoration: none;
InBlock.gif    color: Black;
InBlock.gif    display: inline
-block;
InBlock.gif    width: 
100%;
InBlock.gif    background
-color: White;
ExpandedBlockEnd.gif}

None.gif.ContentView
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border: 0px;
InBlock.gif    padding: 3px 3px 3px 3px;
InBlock.gif    background
-color: White;
InBlock.gif    display: inline
-block;
InBlock.gif    width: 390px;
ExpandedBlockEnd.gif}

None.gif.SepBorder
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border
-top-width: 0px;
InBlock.gif    border
-left-width: 0px;
InBlock.gif    font
-size: 1px;
InBlock.gif    border
-bottom: Gray 1px solid;
InBlock.gif    border
-right-width: 0px;
ExpandedBlockEnd.gif}

None.gif.TopBorder
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border
-right: Gray 1px solid;
InBlock.gif    border
-top: Gray 1px solid;
InBlock.gif    background: #DCDCDC;
InBlock.gif    border
-left: Gray 1px solid;
InBlock.gif    color: black;
InBlock.gif    border
-bottom: Gray 1px solid;
ExpandedBlockEnd.gif}

None.gif.ContentBorder
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border
-right: Gray 1px solid;
InBlock.gif    border
-top: Gray 0px solid;
InBlock.gif    border
-left: Gray 1px solid;
InBlock.gif    border
-bottom: Gray 1px solid;
InBlock.gif    height: 
100%;
InBlock.gif    width: 
100%;
ExpandedBlockEnd.gif}

None.gif.SelectedTopBorder
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    border
-right: Gray 1px solid;
InBlock.gif    border
-top: Gray 1px solid;
InBlock.gif    background: none transparent scroll repeat 
0% 0%;
InBlock.gif    border
-left: Gray 1px solid;
InBlock.gif    color: black;
InBlock.gif    border
-bottom: Gray 0px solid;
ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/hide0511/archive/2006/09/24/513536.html

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值