ASP.NET中的TabStrip
来源:互联网 发布:风云武功排名 知乎 编辑:程序博客网 时间:2024/05/17 01:02
记得在ASP.NET1.1中有一个TabStrip的控件,当时觉得很好用,今天突然想到,于是在2.0里面死命的找,就是没有找到。但是发现了multiview这个控件,研究了一下代码:
<%@ Page Language="C#" %>
<html>
<head>
<script runat="server">
protected void NextButton_Command(object sender, EventArgs e)
{
// Determine which button was clicked
// and set the ActiveViewIndex property to
// the view selected by the user.
if (DevPollMultiView.ActiveViewIndex > -1 & DevPollMultiView.ActiveViewIndex < 3)
{
// Increment the ActiveViewIndex property
// by one to advance to the next view.
DevPollMultiView.ActiveViewIndex += 1;
}
else if (DevPollMultiView.ActiveViewIndex == 3)
{
// This is the final view.
// The user wants to save the survey results.
// Insert code here to save survey results.
// Disable the navigation buttons.
Page4Save.Enabled = false;
Page4Restart.Enabled = false;
}
else
{
throw new Exception("An error occurred.");
}
}
protected void BackButton_Command(object sender, EventArgs e)
{
if (DevPollMultiView.ActiveViewIndex > 0 & DevPollMultiView.ActiveViewIndex <= 2)
{
// Decrement the ActiveViewIndex property
// by one to return to the previous view.
DevPollMultiView.ActiveViewIndex -= 1;
}
else if (DevPollMultiView.ActiveViewIndex == 3)
{
// This is the final view.
// The user wants to restart the survey.
// Return to the first view.
DevPollMultiView.ActiveViewIndex = 0;
}
else
{
throw new Exception("An error occurred.");
}
}
</script>
</head>
<body>
<form ID="Form1" runat="Server">
<h3>MultiView ActiveViewIndex Example</h3>
<asp:Panel id="Page1ViewPanel"
Width="330px"
Height="150px"
HorizontalAlign =Left
Font-size="12"
BackColor="#C0C0FF"
BorderColor="#404040"
BorderStyle="Double"
runat="Server">
<asp:MultiView id="DevPollMultiView"
ActiveViewIndex=0
runat="Server">
<asp:View id="Page1" runat="Server">
<asp:Label id="Page1Label"
Font-bold="true"
Text="What kind of applications do you develop?"
runat="Server">
</asp:Label><br><br>
<asp:RadioButton id="Page1Radio1"
Text="Web Applications"
Checked="False"
GroupName="RadioGroup1"
runat="server" >
</asp:RadioButton><br>
<asp:RadioButton id="Page1Radio2"
Text="Windows Forms Applications"
Checked="False"
GroupName="RadioGroup1"
runat="server" >
</asp:RadioButton><br><br><br>
<asp:Button id="Page1Next"
Text = "Next"
OnClick="NextButton_Command"
Height="25"
Width="70"
runat= "Server">
</asp:Button>
</asp:View>
<asp:View id="Page2"
runat="Server">
<asp:Label id="Page2Label"
Font-bold="true"
Text="How long have you been a developer?"
runat="Server">
</asp:Label><br><br>
<asp:RadioButton id="Page2Radio1"
Text="Less than five years"
Checked="False"
GroupName="RadioGroup1"
runat="Server">
</asp:RadioButton><br>
<asp:RadioButton id="Page2Radio2"
Text="More than five years"
Checked="False"
GroupName="RadioGroup1"
runat="Server">
</asp:RadioButton><br><br><br>
<asp:Button id="Page2Back"
Text = "Previous"
OnClick="BackButton_Command"
Height="25"
Width="70"
runat= "Server">
</asp:Button>
<asp:Button id="Page2Next"
Text = "Next"
OnClick="NextButton_Command"
Height="25"
Width="70"
runat="Server">
</asp:Button>
</asp:View>
<asp:View id="Page3"
runat="Server">
<asp:Label id="Page3Label1"
Font-bold="true"
Text= "What is your primary programming language?"
runat="Server">
</asp:Label><br><br>
<asp:RadioButton id="Page3Radio1"
Text="Visual Basic .NET"
Checked="False"
GroupName="RadioGroup1"
runat="Server">
</asp:RadioButton><br>
<asp:RadioButton id="Page3Radio2"
Text="C#"
Checked="False"
GroupName="RadioGroup1"
runat="Server">
</asp:RadioButton><br>
<asp:RadioButton id="Page3Radio3"
Text="C++"
Checked="False"
GroupName="RadioGroup1"
runat="Server">
</asp:RadioButton><br><br>
<asp:Button id="Page3Back"
Text = "Previous"
OnClick="BackButton_Command"
Height="25"
Width="70"
runat="Server">
</asp:Button>
<asp:Button id="Page3Next"
Text = "Next"
OnClick="NextButton_Command"
Height="25"
Width="70"
runat="Server">
</asp:Button><br>
</asp:View>
<asp:View id="Page4"
runat="Server">
<asp:Label id="Label1"
Font-bold="true"
Text = "Thank you for taking the survey."
runat="Server">
</asp:Label>
<br><br><br><br><br><br>
<asp:Button id="Page4Save"
Text = "Save Responses"
OnClick="NextButton_Command"
Height="25"
Width="110"
runat="Server">
</asp:Button>
<asp:Button id="Page4Restart"
Text = "Retake Survey"
OnClick="BackButton_Command"
Height="25"
Width="110"
runat= "Server">
</asp:Button>
</asp:View>
</asp:MultiView>
</asp:Panel>
</form>
</body>
</html>
如果把代码中的Button放在multiview标签的外面,并且指定对应的ActiveViewIndex就可以实现原来的tabStrip的效果。
- ASP.NET中的TabStrip
- ASP.NET2.0中的TabStrip
- VS 2005中如何实现ASP.NET 1.x中的Tabstrip和Mutipage
- 解决asp.net中tabstrip不能点击的问题
- telerik asp.net 控件学习笔记之————TabStrip / Templates
- TabStrip
- asp.net中的asp:RadioButtonList
- Asp.net中的线程
- ASP.NET中的ViewState
- ASP.NET中的ViewState
- asp.net中的会话
- asp.net中的codebehind
- asp.net中的session
- ASP.NET中的OutOfMemoryException
- ASP.NET中的ViewState
- ASP.NET中的OutOfMemoryException
- asp.net中的session
- ASP.NET中的XML
- 不确定性算法在C++中的表达:一个简化模型
- 自己写一个strcpy(char*dest,char*src),如何在函数内部实现防御性溢出?
- 星星帮忙:2个sql(1)、(2)为何不能等价?
- 后台动态设置前台标签内容和属性
- C#中动态创建控件及事件处理程序
- ASP.NET中的TabStrip
- 父亲
- 用Photoshop两步制作Google Logo
- ASP.NET中的数据绑定:哪个更快
- ASP.NET中给上传图像加水印(版权信息)
- 用python写的一个对象池类
- 人际关系的55个绝招
- 关于C#中timer类
- 数据绑定以及Container.DataItem几种方式与用法分析