0% found this document useful (0 votes)
3 views

ASP.net Practical

The document provides a comprehensive guide on creating ASP.Net applications using various web server controls, including validation, master pages, data binding with ADO.Net, navigation controls, user controls, web parts, and ad rotators. It includes code snippets for implementing login forms, data display using GridView and DataList, and navigation through TreeView and Menu controls. Additionally, it demonstrates the use of XML files for ad rotation and user control for income tax calculation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ASP.net Practical

The document provides a comprehensive guide on creating ASP.Net applications using various web server controls, including validation, master pages, data binding with ADO.Net, navigation controls, user controls, web parts, and ad rotators. It includes code snippets for implementing login forms, data display using GridView and DataList, and navigation through TreeView and Menu controls. Additionally, it demonstrates the use of XML files for ad rotation and user control for income tax calculation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

As: 1Create an ASP.

Net Application using Web Server Controls apply appropriate


validation to it.

%@PageLanguage="C#"AutoEvent Wireup"true"CodeFile-"Default.aspx.cs"Inherits="D
efault"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
<head>
<body>
<center><hl> Login Entry Form <hl><lcenter>
<formid=" form1"runat-"server">
<center>
<tablewidth="700">
<tr>

td><asp:LabellD="Labell"runat-"'server"Text-"Enter UserName"Font
Size="14pt"></asp:Label></td
<td><asp:TextBoxlD="TextBox1"runat-"server"Font-Size="12pt"></asp:TextBox>
<asp:RequiredFieldValidatorlD="RequiredFieldValidatorl"runat-="'server"ErorMessage="E
nter UserName"ControlToValidate-"textbox 1"></asp:RequiredFieldValidator></td></tr>
<tr>
<td><asp:LabellD="Label2"'runat-"server"Text-"Enter Password"Font
Size="14pt"></asp:Label><td>
<td><asp:TextBoxID="TextBox2"runat-"'server"Font-Size="12pt"></asp:TextBox>
<asp:RequiredFieldValidatorlD="RequiredFieldValidator2"runat="server"ErrorMessage="E
nter Password"ControlToValidate-"textbox2"></asp:RequiredFieldValidator></td></tr>
<tr>
<td><asp:LabellD="Label3"'runat-"'server"Text="ReEnter Password"Font
Size="14pt"></asp:Label></td>
<d><asp:TextBoxlD="TextBox3"'runat="server"Font-Size-"12pt"></asp:TextBox>
<asp:CompareValidatorlD="CompareValidatorl "runat="server"ErorMessage-"Not
Equal"ControlToValidate="textbox3"ControlToCompare="textbox2"Operator="Equal"Type
="String"></asp:CompareValidator></td></tr
</table>
<asp:ButtonlD="Button1"runat="server"Text="Submit"Font-Size="12pt"/>
<Jcenter>
</form>
</body>
</htm]>

Login Entry Form


Enter UserName Enter Cser Name
Enter Password
dfgdtgdtgdfg
ReEnter Password hjkihkjh Not Equal
Submit
ASs 2Create an ASP.Net
Step 1: Design Skin File in Application usine Master Pageand Themes and Skins
Theme Folder as :
websMcoc Viual Nao Adrinstaon
Ten Wndew Hale
Oebug

Arp ThemevMSkhntle skin"Delahapa'


HIM
Gener al

e e are
casp:Label runat-"'server" Text="Label" BackColor="Aqua" Font-Size-"14p
conres
casp:TextBox runat='server" Font-Slze="14pt"></asp:TextBox
Crea n
em Sasp:Button runat="server" Text"Button' Font-Bold"14p" BackColora"Pinki

Step 2:Apply Following Code For Master Page:


So@MasterLanguage="C#"AutoEvent Wireup="true"CodeFile-"MasterPage.master.cs"Inhe
rits="MasterPage"%>
<htmlxmlns-"http:/ www.w3.org/1999/xhtml">
<headrunat-"server"s
<title>Untitled Page</title>
<asp:ContentPlaceHolderid="head"runat="server">
Vasp:ContentPlaceHolder>
</head>
<body>
<center><h6>D.E.Socities </h6></center>
<center><hl> M.D.Palesha Commerce College, Dhule</hl></center>
<hr>
<marquee> Courses are BCOM, BMS and MMS </marquee>
<hr>
<formid="form1"runat="'server">
<asp:ContentPlaceHolderid="ContentPlaceHolder1"'runat="server">
<lasp:ContentPlaceHolder>
</form>
</body>
<htm>
Step 3:Design the contentPage
<o@PageLanguage="C#"MasterPageFile="/MasterPage.master"AutoEvent Wireup-"true"
CodeFile="Default.aspx.cs"Inherits=" Default"Title="Untitled Page"%>
<asp:ContentID="Content1"ContentPlaceHolderlD="head"Runat="Server">
<lasp:Content>
<asp:ContentID="Content2"ContentPlaceHolderlD="ContentPlaceHolder1"Runat="Server">
<asp:Label|D="Label 1"runat="'server"Text="Enter Rollno"></asp:Label>
<asp:TextBoxID="TextBox1 "runat="server"></asp:TextBox>
<br>
<asp:LabellD="Label2"runat="server"Text="Enter Name"></asp:Label>
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
<br>
<asp:Button|D="Button1"runat="server"Text-"Submit">
<lasp:Content>
Step 4:0utput Is:
Uvted Pae Wndgs otesnet Evporer

Fde Ed Ves feortes Tocs Help

2favories
Page de,
Jnted Page

DL Secitiet

M.D.Palesha Commerce College, Dhule


Corses ase BCOM BMS nd MMS

Lebd erwerwerwe
Labe werwel
Button
Ass no 3: Create an ASP.Net Application to
demonstrate binding of
GridView,DataList, Repeater.DropDownList. RadioButtonList, CheckBoxList,Controls using
ADO.Net
Step 1: Create Database in MSACCESS, also create table and add few records in it.
Views Tools Show/Hide
All Tables
Stud
Stud
Field Name Data Typel
Stud:Table B Rollno Number
StudName Text
StudClass Text
StudPer Number

Step 2: Add SQLDataSource,all different Controls:


<Yo@PageLanguage-"C#"AutoEvent Wireup="true"CodeFile="Default.aspx.cs"Inherits="_D
efault"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml 1/DTD/xhtml1-transitional.dtd">

<htmlxmlns-"http:/www.w3.org/1999/xhtml">
<headrunat="'server">
<title>Untitled Page</title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:SqlDataSourcelD="SqlDataSourcel"runat-"'server"
ConnectionString-"<%S ConnectionStrings:tybmsConnectionString %>"
ProviderName="<%$ ConnectionStrings:tybmsConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Stud]"></asp:SqlDataSource>

<asp:GridViewlD="GridView1 "runat="server"AutoGenerateColumns="False"
DatakeyNames="Rollno"DataSourcelD="SqlDataSource1">
<Columns>
<asp:BoundFieldDataField="Rollno"HeaderText="Rollno"ReadOnly="True"
SortExpression="Rollno">
<asp:BoundFieldDataField="StudName"HeaderText-"StudName"
SortExpression="Stud Name"/>
<asp:BoundFieldDataField="StudClass"HeaderText-"StudClass"
SortExpression="Stud Class"/>
<asp:BoundFieldDataField="StudPer"HeaderText="StudPer"
SortExpression="StudPer"/>
</Columns>
</asp:GridView>
<asp:DataList0D="DataList1 "runat="server"DatakeyField="Rollno"
DataSourcelD="SqlDataSource l">
<ItemTemplate>
Rollno:
<asp:LabellD="RollnoLabel'runat="server"Text<%# Eval("Rollno") %>>
<br/>
StudName:
<asp:LabellD="StudNameLabel"'runat="server"Text=<%# Eval("StudName")
<br>
StudClass:
<asp:LabelID="StudClassLabel "runat-="server"Text='<%# Eval("StudClass") %/
<br>
StudPer:
<asp:LabellD="StudPerLabel"'runat-"'server"Text-<%# Eval("StudPer") %>
<br>
<br>
<ItemTemplate>
</asp:DataList>

<asp:RepeaterlD="Repeater1 "runat-"server"DataSourcelD="Sq|DataSourcel">
<HeaderTemplate> RollNo : Name <ul></HeaderTemplate>
<TtemTemplate>i><%# Eval("Rollno") %><%# Eval("StudName")
%><i></ItemTemplate>
<FooterTemplate></ul><FooterTemplate>
<Jasp:Repeater>
<asp:DropDownListlD="DropDownListl "runat="server"
DataSourcelD="SqlDataSourcel"DataTextField="StudName"
DataValueField="StudName">
<asp:DropDownList>
<asp:ListBoxID="ListBox 1"runat-"server"DataSourcelD="SqlDataSource1"
DataTextField="StudClass"DataValueField-"StudClass"></asp:ListBox>
</div>
</form>
<body>
<html>
AssNo 4: Write a code to
demonstrate navigation controls.
A) TreeView:

<asp:TreeViewlD="Tree View1"runat-"server">
<Nodes>
<asp:TreeNodeText="Progranmming Languages"Value-"Programming Languages"?
<asp:TreeNodeNavigateUrl="Default2.
Value-"Java aspx"Text="Java Programming"
Programming"><lasp:TreeNode>
<asp:TreeNodeNavigateUrl="Default3.
Value="Python aspx"Text-"Python Programming"
Programming"></asp:TreeNode>
</asp:TreeNode>
<Nodes>
</asp:TreeView>

Programming Languages
JavaProgramming
Python Programming
B) Menu

<asp:MenulD="Menul"runat="server"Height-"27px"Orientation="Horizontal"
Width-"884px">
<Items>
<asp:MenultemNavigateUrl="-Default2.aspx"Text="Java" Value="Java'>
</asp:Menultem>
<asp:MenultemNavigateUrl="-Default3.aspx"Text="Python"Value-"Python">
</asp:Menultem>
Items>
</asp:Menu>
C) SiteMapPath:

<?xml version="1.0" encoding="utf-8" ?>


<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url-"default.aspx" title="Programming" description="">
<siteMapNode url-"default2.aspx" title="Java" description=""
<siteMapNode url="default3.aspx" title="Python" description="" >
</siteMapNode>
</siteMapNode>
</siteMap>
Add SiteMapPath Control on Every WebPage
<asp:SiteMapPathlD="SiteMapPath1"runat-"server">
<lasp:SiteMapPath>
AssNo5: Working with User Controls
Step 1:Start with new webapplication-> Add Newy ltem
->UserControl
Step 2:Place controls on it as:

Yo@ControlLanguage="C#"AutoEvent Wireun="rue"CodeFile="WebUserControl.ascx.cs"1
nherits="WebUserControl"%> server"Text="Enter Annual Income"Font
<asp:LabellD="Labell"runat="'
Size="18pt"></asp:Label>
<asp:TextBoxlD="TextBox 1"runat="server"Font-Size="18pt"></asp:TextBox>
<asp:LabellD="Label2"runat-"server"Text="IncomeTax is->"Font
Size="18pt"></asp:Label>
<asp:TextBoxlD="TextBox2"runat=-"server"Font-Size="18pt"><lasp:TextBox?
Sasp:ButtonlD="Buttonl"runat="server"Text="CIick"onclick="Buttonl_Click"Font
Size-"18pt">
Step 3: Apply the coding for button as:
protectedvoid Buttonl_Click(object sender, EventArgs e)
double inc= Convert.ToDouble(TextBox 1.Text);
double tax =0;
if (ine <= 1000000)
tax =0;
else
tax = (inc - 1000000) * 0.10;
TextBox2.Text = tax.ToString);

the page, to get the effect


Step 4: Add Default.aspx page, drag the user control on
<%@PageLanguage="C#"AutoEvent Wireup="true"CodeFile="Default2.aspx.cs"Inherits="D
efault2"%>
<o@Registersrc="WebUserControl.ascx"tagname="\WebUserControl"tagprefix="uc|"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
<head>
<body>
<formid="form1"runat="server">
<div>
<ldiv>
<uc1:WebUserControllD="WebUserControl1"runat="serve">
<ucl:WebUserControl|D="WebUserControl2"runat="server">

</form>
<body>
</htm>
Assno6: Create an ASP .NET application to demonstrate Web parts
S7o@PageLanguage="C#"AutoEvent Wireup="true"CodeFile-"Default.aspx.cs"Inherits="D
efault"%>

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat-"server">
<title>Untitled Page</title>
</head>
<body>
<formid-="form1"runat="server">
<asp: WebPartManagerlD="WebPartManager1"runat-"server">
</asp:WebPartManager>
<tablewidth="100%">
<tr>
<td>
<asp:WebPartZonelD="WebPartZonel"runat="'server">

</asp:WebPartZone>
<asp:CalendarlD="Calendarl"'runat-"'server'"></asp:Calendar>
</td>
<td>
<asp:LabellD="Label1"runat-"server"Text-"Label"></asp:Label>
</td>
<>
</table>
</form>
</body>
<htm>
AssNo7: Write a codeto demonstrate ADRotator Control
XML File:

<?xml version="1.0" encoding="utf-8" ?>


<Advertisements>
<Ad>
<ImageUrl>imgl.jpg</AmageUrl>
<Impressions>10</Impressions>
</Ad>
<Ad>

<ImageUr>img2.png</ImageUrl>
<Impressions>2</mpressions>
</Ad>
<Ad>
<ImageUr>img3jpg</ImageUrl>
<Impressions>7</mpressions>
</Ad>
<Ad>
<ImageUr>img4.jpg</lmageUrl>
<Impressions>1</mpressions>
<JAd>
</Advertisements>

Control:
<asp:AdRotatorlD="AdRotatorl"runat="server"AdvertisementFile="XMLFile.xml">

You might also like