a. Design ASP.NET page and perform validation using various Validation Controls
b. Design an APS.NET master web page and use it other (at least 2-3) content pages.
c. Design ASP.NET Pages with various Navigation Controls
a. Design ASP.NET page and perform validation using various Validation Controls:
Aspx:
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="PR5A.aspx.cs"Inherits="WebApplication1.PR5A"%>
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<br/>
User Name: <asp:TextBoxID="txtusername"runat="server"></asp:TextBox>
<asp:RequiredFieldValidatorID="vldUserName"runat="server"
ErrorMessage="You must enter a user name."
controltovalidate="txtusername"/><br/>
<hr/>
<br/>
<br/>
Password:
<inputid="txtPassword"type="password"runat="server"/>
<asp:RequiredFieldValidatorID="vldPassword"runat="server"
errormessage="You must enter a password."
controltovalidate="txtpassword"/><br/>
<br/>
Password (Retype ):
<inputid="txtRetype"type="password"runat="server"/>
<asp:CompareValidatorID="vldRetype"runat="server"
errormessage="Your password does not match."
controltocompare="txtpassword"controltovalidate="txtretype"/>
<br/>
<hr/>
<br/>
<br/>
E-mail: <asp:TextBoxID="txtemail"runat="server"></asp:TextBox>
<asp:RegularExpressionValidatorID="vldEmail"runat="server"
errormessage="Email is missing the @ sysmbol."
validationexpression=".+@.+"controltovalidate="txtemail"/><br/>
<br/>
Age:
<asp:TextBoxID="txtage"runat="server"></asp:TextBox>
<asp:RangeValidatorID="vldAge"runat="server"
errormessage="Age should be between 5 and 100"Type="Integer"
maximumvalue="100"MinimumValue="5"
controltovalidate="txtAge"/><br/>
<br/>
Referrer Code:
<asp:TextBoxID="txtcode"runat="server"></asp:TextBox>
<asp:CustomValidatorID="vldCode"runat="server"
errormessage="Try a string that starts with 014"
controltovalidate="txtCode"/> <br/>
<hr/>
<br/>
<br/>
<br/>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label>
<asp:ButtonID="btnsubmit"runat="server"onclick="btnsubmit_Click"
style="text-align: center"Text="Submit"/>
<asp:ValidationSummaryID="ValidationSummary1"runat="server"
DisplayMode="BulletList"ShowSummary="true"HeaderText="Errors:"/>
<br/>
<br/>
</div>
</form>
</body>
</html>
Aspx.cs:
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespace WebApplication1
{
publicpartialclassPR5A : System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
}
protectedvoidbtnsubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Label1.Text="Thank you";
}
else
{
Label1.Text = "Fill up all the fields";
}
}
}
}
OUTPUT:
b. Design an APS.NET master web page and use it other (at least 2-3) content pages:
Webform1.aspx
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:SiteMapDataSourceID="SiteMapDataSource1"runat="server"StartingNodeUrl="~/WebForm1.aspx"/>
<asp:TreeViewID="TreeView1"runat="server"DataSourceID="SiteMapDataSource1">
</asp:TreeView>
<asp:MenuID="Menu1"runat="server"DataSourceID="SiteMapDataSource1">
</asp:Menu>
<asp:SiteMapPathID="SiteMapPath1"BackColor="SkyBlue"CurrentNodeStyle-Font-Bold="true"ForeColor="White"runat="server">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>
Web.sitemap
<?xmlversion="1.0"encoding="utf-8" ?>
<siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNodeurl="WebForm1.aspx"title="Home"description="Home">
<siteMapNodeurl="Products.aspx"title="Products"description="Products details">
<siteMapNodeurl="Apparele.aspx"title="Apparels"description="Dress" />
<siteMapNodeurl="cosmetics.aspx"title="cosmetics"description="cosmetics" />
<siteMapNodeurl="hardware.aspx"title="hardware"description="hardware" />
<siteMapNodeurl="software.aspx"title="software"description="software" />
</siteMapNode>
<siteMapNodeurl="Books.aspx"title="Library"description="Library">
<siteMapNodeurl="Computer.aspx"title="Computer"description="Computer" />
<siteMapNodeurl="Sciencefication.aspx"title="Sciencefication"description="Sciencefication" />
<siteMapNodeurl="Space.aspx"title="Space"description="Space" />
</siteMapNode>
</siteMapNode>
</siteMap>
OUTPUT:
c. Design ASP.NET Pages with various Navigation Controls:
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<linkhref="StyleSheet1.css"rel="stylesheet">
<asp:ContentPlaceHolderID="head"runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<formid="form1"runat="server">
<divid="con">
<asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server">
</asp:ContentPlaceHolder>
<headerid="header">
<h1>Master page demo</h1>
</header>
<navid="nav">
<ul>
<li><ahref="Home.aspx">Home</a></li>
<li><ahref="#">About</a></li>
<li><ahref="#">Article</a></li>
<li><ahref="#">Contact</a></li>
</ul>
</nav>
<asideid="side">
<h1>news</h1>
<ahref="#"><p>creating html website</p></a>
<ahref="#"><p>css</p></a>
</aside>
<footerid="footer1">Copyright</footer>
</div>
</form>
</body>
</html>
body {
}
#header {
color:#ff6a00;
text-align:center;
font-size:20px;
}
#nav {
background-color: #fff;
padding: 5px;
}
ul {
list-style-type: none;
}
lia {
color: #1136e5;
font-size: 30px;
column-width: 5%;
}
li {
display: inline;
padding-left: 2px;
column-width: 20px;
}
a {
text-decoration: none;
margin-left: 20px;
}
lia:hover {
background-color: #b6ff00;
color: #ff1654;
padding: 1%;
}
#footer {
background-color: #c7efcf;
text-align: center;
padding-bottom: 5%;
font-size: 30px;
}
#con {
border: double;
border-color: burlywood;
}
<asp:ContentID="Content1"ContentPlaceHolderID="head"runat="server">
hello world...!
</asp:Content>
<asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"runat="server">
Body goes here...!
</asp:Content>
OUTPUT:
0 Comments