Image控件导航栏
<asp:ImageMap ID="ImageMap1" runat="server" BorderColor="Black" BorderWidth="3" ImageUrl="~/未标题-nav.png" ImageAlign="AbsMiddle" CssClass="imagemap">
<asp:RectangleHotSpot AlternateText="教育教学" Bottom="60" Right="200" NavigateUrl="https://www.baidu.com" />
<asp:RectangleHotSpot AlternateText="科学研究" Bottom="60" Right="500" NavigateUrl="https://www.baidu.com" />
<asp:RectangleHotSpot AlternateText="招生就业" Bottom="60" Right="700" NavigateUrl="https://www.baidu.com" />
<asp:RectangleHotSpot AlternateText="交流合作" Bottom="60" Right="900" NavigateUrl="https://www.baidu.com" />
<asp:RectangleHotSpot AlternateText="资源信息" Bottom="60" Right="1200" NavigateUrl="https://www.baidu.com" />
<asp:RectangleHotSpot AlternateText="校园文化" Bottom="60" Right="1400" NavigateUrl="https://www.baidu.com" />
</asp:ImageMap>
<table style="height:86px;width:700px">
<tr>
<td style="width:95px;text-align:center"><asp:LinkButton ID="LinkButton1" runat="server">首页</asp:LinkButton></td>
<td style="width:95px;text-align:center"><asp:LinkButton ID="LinkButton2" runat="server">首页</asp:LinkButton></td>
<td style="width:95px;text-align:center"><asp:LinkButton ID="LinkButton3" runat="server">首页</asp:LinkButton></td>
<td style="width:95px;text-align:center"><asp:LinkButton ID="LinkButton4" runat="server">首页</asp:LinkButton></td>
<td style="width:95px;text-align:center"><asp:LinkButton ID="LinkButton5" runat="server">首页</asp:LinkButton></td>
</tr>
</table>
页面注册
<div>
<table class="auto-style1">
<tr>
<td class ="auto-style3" style="text-align:right">姓名</td>
<td class="auto-style5">
<asp:TextBox ID="txtName" runat="server" Width="120px"></asp:TextBox>
</td>
<td class="auto-style2">
<asp:RequiredFieldValidator ID="rfvName" runat="server" ErrorMessage="请输入姓名" ControlToValidate="txtName" Display="Dynamic" SetFocusOnError="true">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style ="text-align:right">密码</td>
<td class="auto-style6">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="120px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ErrorMessage="请输入密码" ControlToValidate="txtPassword" Display="Dynamic" SetFocusOnError="true">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align:right">确认密码</td>
<td class="auto-style6">
<asp:TextBox ID="txtPasswordAgain" runat="server" TextMode="Password" Width="120px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvPasswordAgain" runat="server" ErrorMessage="请输入确认密码" ControlToValidate="txtPasswordAgain" Display="Dynamic" SetFocusOnError="true">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align:right">生日</td>
<td class="auto-style6">
<asp:TextBox ID="txtBirthday" runat="server" Width="120px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvBirthday" runat="server" ErrorMessage="请输入生日" ControlToValidate="txtBirthday" Display="Dynamic" SetFocusOnError="true">*</asp:RequiredFieldValidator>
<asp:RangeValidator ID="rvBirthday" runat="server" ErrorMessage="日期应在1900-1-1到2024-6-19之间" ControlToValidate="txtBirthday" Display="Dynamic" MaximumValue="2024-6-19" MinimumValue="1900-1-1" Type="Date" SetFocusOnError="true"></asp:RangeValidator>
</td>
</tr>
</table>
</div>
页面跳转重定向
button按钮下cs界面:Response.Redirect("xxxx.aspx");
LinkDataSource/GridView显示表数据
建立LinqDSGrid.aspx。添加LinqDataSource和GridView控件各一个,并分别设置控件的ID属性值为ldsCategory和gvCategory。
单击ldsCategory控件的智能标记,选择“配置数据源”命令呈现的对话框,选择MyPetShopEntities。单击下一步按钮“配置数据选择”对话框。
<div>
<asp:LinqDataSource ID="ldsCategory" runat="server" ContextTypeName="MyPetShopEntities" EntityTypeName="" TableName="Table"></asp:LinqDataSource>
<asp:GridView ID="gvCategory" runat="server" AutoGenerateColumns="False" DataSourceID="ldsCategory">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
</div>
基于Entity Framework利用LINQ查询数据
protected void BtnOrder_Click(object sender,EventArgs e)
{
MyPetShopEntities db= new MyPetShopEntities();
var results = db.Product.OrderByDescending(p=>p.UnitCost);
gvProduct.DataSource=results.ToList();
gvProduct.DataBind();
}
数据库
CREATE TABLE [dbo].[Table] (
[CategorId] INT NOT NULL,
[Name] NVARCHAR (50) NULL,
[Descn] NVARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([CategorId] ASC)
);
INSERT INTO [dbo].[Table] ([CategorId], [Name], [Descn]) VALUES (1, N'Fish', N'Fish')
CREATE TABLE [dbo].[Table2] (
[Id] INT NOT NULL,
[Name] NVARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
INSERT INTO [dbo].[Table2] ([Id], [Name]) VALUES (11, N'Fishs')