CommandName 值 CommandArgument 值
NextView
(没有值)
PrevView
(没有值)
SwitchViewByID
要切换到的 View 控件的 ID。
SwitchViewByIndex
要切换到的 View 控件的索引号。
下面的示例显示一个包含三个 View 控件的 MultiView 控件。每个 View 控件包含一个移动到特定 View 控件的 Button 控件。
示例代码
--><asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
View 1<br />
<br />
<asp:Button ID="Button1" runat="server"
CommandArgument="View2"
CommandName="SwitchViewByID"
Text="Go to View2" />
</asp:View>
<asp:View ID="View2" runat="server">
View 2<br />
<br />
<asp:Button ID="Button2" runat="server"
CommandArgument="View3"
CommandName="SwitchViewByID"
Text="Go to View 3" />
</asp:View>
<asp:View ID="View3" runat="server">
View 3<br />
<br />
<asp:Button ID="Button3" runat="server"
CommandArgument="View1"
CommandName="SwitchViewByID"
Text=Go to View 1" />
</asp:View>
</asp:MultiView></div>
这种方法可以很简单的不需要代码实现View的切换.
第二种方法就是代码控制的方式.
MultiView.ActiveViewIndex和MultiView.SetActiveView方法可以实现.
它们的区别就是:
MultiView.ActiveViewIndex方法是设置View的索引值.View 控件的索引是由它在 MultiView 控件中的声明顺序确定的。例如,在 MultiView 控件中声明的第一个 View 控件的索引为 0。
MultiView.SetActiveView方法是将指定的 View 控件设置为 MultiView 控件的活动视图。