1. 程式人生 > 實用技巧 >asp.net2.0中MultiView應用例項

asp.net2.0中MultiView應用例項

在asp.net1.1中曾經推出了TreeView、MultiPage等外掛(因為不是vs2003內建的),需要下載安裝相關的外掛才能使用,這些當年我也曾用過,不過感覺用起來不是太方便(到伺服器上部署時還需要安裝一遍),現在到vs2005中這些都成為內建控制元件了,極大的方便了開發和部署,TreeView控制元件似乎沒有太多要說的,今天我就展示一下MultiPage控制元件的升級產品MultiView控制元件。 設計時檢視:
以下是執行時的截圖:
前臺aspx程式碼如下:
<%@PageLanguage="C#"AutoEventWireup="true
"CodeFile="MultiViewDemo.aspx.cs"Inherits="MultiViewDemo"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server"
>
<title>MultiView應用例項</title>
<styletype="text/css">
body
{
font-size
:11pt;
font-family
:宋體;
}
.mainTitle
{
font-size
:12pt;
font-weight
:bold;
font-family
:宋體;
}
.commonText
{
font-size
:11pt;
font-family
:宋體;
}
.littleMainTitle
{
font-size
:10pt;
font-weight
:bold;
font-family
:宋體;
}
.TopTitle
{
border
:0px
;
font-size
:10pt;
font-weight
:bold;
text-decoration
:none;
color
:Black;
display
:inline-block;
width
:100%;
}
.SelectedTopTitle
{
border
:0px;
font-size
:10pt;
text-decoration
:none;
color
:Black;
display
:inline-block;
width
:100%;
background-color
:White;
}
.ContentView
{
border
:0px;
padding
:3px3px3px3px;
background-color
:White;
display
:inline-block;
width
:390px;
}
.SepBorder
{
border-top-width
:0px;
border-left-width
:0px;
font-size
:1px;
border-bottom
:Gray1pxsolid;
border-right-width
:0px;
}
.TopBorder
{
border-right
:Gray1pxsolid;
border-top
:Gray1pxsolid;
background
:#DCDCDC;
border-left
:Gray1pxsolid;
color
:black;
border-bottom
:Gray1pxsolid;
}
.ContentBorder
{
border-right
:Gray1pxsolid;
border-top
:Gray0pxsolid;
border-left
:Gray1pxsolid;
border-bottom
:Gray1pxsolid;
height
:100%;
width
:100%;
}
.SelectedTopBorder
{
border-right
:Gray1pxsolid;
border-top
:Gray1pxsolid;
background
:nonetransparentscrollrepeat0%0%;
border-left
:Gray1pxsolid;
color
:black;
border-bottom
:Gray0pxsolid;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<fieldsetstyle="width:400px">
<legend>MultiView應用例項</legend>
<tablecellpadding="0"cellspacing="0"width="100%"border="0">
<tr>
<td>
<tablerunat="server"cellpadding="0"cellspacing="0"width="100%"border="0">
<trstyle="height:22px">
<tdclass="SelectedTopBorder"id="Cell1"align="center"style="width:80px;">
<asp:LinkButtonID="lButtonCompany"runat="server"OnClick="lButtonCompany_Click">公司介紹</asp:LinkButton></td>
<tdclass="SepBorder"style="width:2px;height:22px;"></td>
<tdclass="TopBorder"id="Cell2"align="center"style="width:80px;">
<asp:LinkButtonID="lButtonProduct"runat="server"OnClick="lButtonProduct_Click">產品介紹</asp:LinkButton></td>
<tdclass="SepBorder"style="width:2px;height:22px;"></td>
<tdclass="TopBorder"id="Cell3"align="center"style="width:80px;">
<asp:LinkButtonID="lButtonContact"runat="server"OnClick="lButtonContact_Click">聯絡我們</asp:LinkButton></td>
<tdclass="SepBorder"style="width:2px;height:22px;"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<tableclass="ContentBorder"cellpadding="0"cellspacing="0"width="100%">
<tr>
<tdvalign="top">
<asp:MultiViewID="mvCompany"runat="server"ActiveViewIndex="0">
<asp:ViewID="View1"runat="server">
我們公司是一個正在上升時期的公司。公司目前有中科院計算機院士3人,博士後32人,博士63人,研究生120人,本科生356人,具有非常強大研發實力。
</asp:View>
<asp:ViewID="View2"runat="server">
我們有豐富的產品線,還可以為使用者單獨定製。目前有吹牛軟體、撒謊軟體、包二奶軟體等等,正在研發的軟體有火星定位軟體、超時空軟體等等。
</asp:View>
<asp:ViewID="View3"runat="server">
我們的聯絡方式是119,傳真是110,客服電話是120,售後電話114。
</asp:View>
</asp:MultiView>&nbsp;
</td>
</tr>
</table>
</td>
</tr>
</table>
</fieldset>

</div>
</form>
</body>
</html>