Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
×

# Hems

2,167 views

Published on

• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

### Hems

1. 1. 090360116058 Dot Net Technology PRACTICAL NO: 1AIM: Write a program for Arithmetic Calculator using Console &Windows Application in C# & VB.NET. Console Calculator.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleApplicationCalculator{ class Program { static void Main(string[] args) { int a, b, n; Console.WriteLine("Calculator in C# Console Application "); Console.WriteLine("enter the value of A"); a = int.Parse(Console.ReadLine()); Console.WriteLine("enter the value of B"); b = int.Parse(Console.ReadLine()); Console.WriteLine("enter choice n 1 = Addition n 2 = Substraction n 3 =Multiplication n 4 = Division"); n = int.Parse(Console.ReadLine()); Program p = new Program(); if (n == 1) { p.add(a, b); } else if (n == 2) { p.sub(a, b); } else if (n == 3) { p.mul(a, b); } else if (n == 4) { p.div(a, b); } else { Console.WriteLine("YOU ARE ENTERING WRONG CHOICE"); } Console.ReadKey(); } public void add(int a, int b)Om Shanti Engg. College - 2012 1
2. 2. 090360116058 Dot Net Technology { int c; c = a + b; Console.WriteLine("Addition is " + c); } public void sub(int a, int b) { int c; c = a - b; Console.WriteLine("Substraction is " + c); } public void mul(int a, int b) { int c; c = a * b; Console.WriteLine("Multiplication is " + c); } public void div(int a, int b) { int c; c = a / b; Console.WriteLine("Division is " + c); } }}Om Shanti Engg. College - 2012 2
3. 3. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 3
4. 4. 090360116058 Dot Net Technology Console Calculator.vbModule Module1 Sub Main() Dim a, b, c As Integer Console.WriteLine("Enter Value of a") a = Convert.ToInt16(Console.ReadLine()) Console.WriteLine("Enter Value of a") b = Convert.ToInt16(Console.ReadLine()) c = a + b Console.WriteLine("Addition") Console.WriteLine(+c) c = a - b Console.WriteLine("Substraction") Console.WriteLine(+c) c = a * b Console.WriteLine("Multiplication") Console.WriteLine(+c) c = a / b Console.WriteLine("Division") Console.WriteLine(+c) Console.ReadKey() End SubEnd ModuleOm Shanti Engg. College - 2012 4
5. 5. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 5
6. 6. 090360116058 Dot Net Technology Windows Calculator.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace VBWindowsFormsApplicationCalculator{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Button1_Click(object sender, EventArgs e) { txtAns.Text = (Convert.ToInt32(txtA.Text) +Convert.ToInt32(txtB.Text)).ToString(); } private void Button2_Click(object sender, EventArgs e) { txtAns.Text = (Convert.ToInt32(txtA.Text) -Convert.ToInt32(txtB.Text)).ToString(); } private void Button3_Click(object sender, EventArgs e) { txtAns.Text = (Convert.ToInt32(txtA.Text) *Convert.ToInt32(txtB.Text)).ToString(); } private void Button4_Click(object sender, EventArgs e) { txtAns.Text = (Convert.ToInt32(txtA.Text) /Convert.ToInt32(txtB.Text)).ToString(); } }}Om Shanti Engg. College - 2012 6
7. 7. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 7
8. 8. 090360116058 Dot Net Technology Windows Calculator.vbPublic Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click TextBox3.Text = Convert.ToInt32(TextBox1.Text) +Convert.ToInt32(TextBox2.Text) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click TextBox3.Text = Convert.ToInt32(TextBox1.Text) -Convert.ToInt32(TextBox2.Text) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button3.Click TextBox3.Text = Convert.ToInt32(TextBox1.Text) *Convert.ToInt32(TextBox2.Text) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button4.Click TextBox3.Text = Convert.ToInt32(TextBox1.Text) /Convert.ToInt32(TextBox2.Text) End SubEnd ClassOm Shanti Engg. College - 2012 8
9. 9. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 9
10. 10. 090360116058 Dot Net Technology PRACTICAL NO: 2AIM: Implement a C# Application to Study Inheritance , Constructor andOverloading. Inheritance.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleInheritance{ class Program { static void Main(string[] args) { Console.WriteLine("Inheritance Programn"); Console.WriteLine("Creating Object of Derive classn"); Derive d=new Derive(); Console.WriteLine("Calling Base class method"); d.Display(); Console.WriteLine("Calling Derive class method"); d.Print(); Console.ReadKey(); } } class BaseClass { public void Display() { Console.WriteLine("This is Base class Display() methodn"); } } class Derive :BaseClass { public void Print() { Console.WriteLine("This is derive class Print() method"); } }}Om Shanti Engg. College - 2012 10
11. 11. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 11
12. 12. 090360116058 Dot Net Technology ConstuctorOverloding.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleConstructorOverLoading{ class Program { public Program() { Console.WriteLine("This is Default Constructorn"); } public Program(String nm) { Console.WriteLine("This is one Parameter Constructor"); Console.WriteLine("My Name is : " + nm + "n"); } public Program(int a, string nm) { Console.WriteLine("This is two Parameter Constructor"); Console.WriteLine("My Name is : " + nm + " and i am : " + a + " years old"); } ~Program() { Console.WriteLine("I am calling Destructor"); } public static void Main(string[] args) { Console.WriteLine("This is Costructor and Destructor in C#n"); Program prg = new Program(); Program prg1 = new Program("abc"); Program prg2 = new Program(20, "abc"); Console.ReadKey(); } }}Om Shanti Engg. College - 2012 12
13. 13. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 13
14. 14. 090360116058 Dot Net Technology PRACTICAL NO: 3AIM:Write a Programm to Demostrate the use of property and indexer. Read & Write Property.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleProperty{ class Program { private string BookName = "abc"; private int BookPrice = 500; public string MyBookName { get { return BookName; } set { BookName = value; } } public int MyBookPrice { get { return BookPrice; } set { BookPrice = value; } } public override string ToString() { return ("BookName is : " + BookName + " Price is : " + BookPrice); } static void Main(string[] args) { Program p = new Program(); Console.WriteLine("This is Read & Write Property Programn"); Console.WriteLine("Default values is :"); Console.WriteLine(p+"n"); p.BookName = ".net Black Book"; p.BookPrice = 450; Console.WriteLine("Changed Value is :"); Console.WriteLine(p); Console.ReadKey(); } } }Om Shanti Engg. College - 2012 14
15. 15. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 15
16. 16. 090360116058 Dot Net Technology Read Only Property.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleProperty2{ class ReadOnly { private string BookName = "abc"; private int BookPrice = 500; public ReadOnly() { } public ReadOnly(String Name,int Price) { BookName = Name; BookPrice = Price; } public string MyBookName { get { return BookName; } } public int MyBookPrice { get { return BookPrice; } } public override string ToString() { return ("BookName is : " + BookName + " and Price is : " + BookPrice); } static void Main(string[] args) { ReadOnly p = new ReadOnly(); Console.WriteLine("This is Read only Propertyn"); Console.WriteLine("Default values is :"); Console.WriteLine(p + "n"); ReadOnly p1 = new ReadOnly(".net Black Book", 450); Console.WriteLine("Changed Value is :"); Console.WriteLine(p1); Console.ReadKey(); } }}Om Shanti Engg. College - 2012 16
17. 17. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 17
18. 18. 090360116058 Dot Net Technology Static Property.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace CSConsoleProperty3{ class Static { static void Main(string[] args) { Console.WriteLine("Static Property Programn"); Console.WriteLine("Number of Object : {0}",CounterClass.NumberOfObject); CounterClass Object1 = new CounterClass(); Console.WriteLine("Number of Object : {0}", CounterClass.NumberOfObject); CounterClass Object2 = new CounterClass(); Console.WriteLine("Number of Object : {0}", CounterClass.NumberOfObject); CounterClass Object3 = new CounterClass(); Console.WriteLine("Number of Object : {0}", CounterClass.NumberOfObject); Console.ReadKey(); } } public class CounterClass { private static int n = 0; public CounterClass() { n++; } public static int NumberOfObject { get { return n; } set { n = value; } } }}Om Shanti Engg. College - 2012 18
19. 19. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 19
20. 20. 090360116058 Dot Net Technology Indexer.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace indexer{ class indexers { int[] a = new int[3]; public int this[int index] { get { if (index < 0 && index > 3) { return 0; } else { return a[index]; } } set { a[index] = value; } } } class Program { static void Main(string[] args) { Console.WriteLine("This is indexer Programn"); indexers i = new indexers(); i[0] = 100; i[1] = 200; i[2] = 300; for (int j = 0; j <= 2; j++) { Console.WriteLine("Value is : " + i[j]); } Console.WriteLine("Changing values"); i[0] = 101; i[1] = 202; i[2] = 303; for (int j = 0; j <= 2; j++) { Console.WriteLine("Value is : " + i[j]); } Console.ReadKey(); } } }Om Shanti Engg. College - 2012 20
21. 21. 090360116058 Dot Net Technology OUTPUT :Om Shanti Engg. College - 2012 21
22. 22. 090360116058 Dot Net Technology PRACTICAL NO: 4AIM: Write a Program for explaining events and Delegates in C# .NET. Events.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace events{ public delegate void eventhandler(); class Program { public static event eventhandler show; static void Main(string[] args) { Console.WriteLine("This is events Programn"); show += new eventhandler(Dog); show += new eventhandler(Cat); show += new eventhandler(Mouse); show += new eventhandler(Mouse); show.Invoke(); Console.ReadKey(); } static void Dog() { Console.WriteLine("Dog"); } static void Cat() { Console.WriteLine("Cat"); } static void Mouse() { Console.WriteLine("Mouse"); } }}Om Shanti Engg. College - 2012 22
23. 23. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 23
24. 24. 090360116058 Dot Net Technology Delegates.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace delegates{ class Program { public delegate int calci(int i, int j); public static int add(int a, int b) { return a + b; } public static int sub(int a, int b) { return a - b; } public static int mul(int a, int b) { return a * b; } public static int div(int a, int b) { return a / b; } static void Main(string[] args) { Console.WriteLine("This is delegates Programn"); calci c; c = add; Console.WriteLine("add {0}", c.Invoke(50, 20)); c = sub; Console.WriteLine("sub {0}", c.Invoke(100, 20)); c = mul; Console.WriteLine("mul {0}", c.Invoke(50, 25)); c = div; Console.WriteLine("div {0}", c.Invoke(30, 30)); Console.ReadKey(); } }}Om Shanti Engg. College - 2012 24
25. 25. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 25
27. 27. 090360116058 Dot Net TechnologyOUTPUT :.Om Shanti Engg. College - 2012 27
28. 28. 090360116058 Dot Net Technology PRACTICAL NO: 6AIM: Implement a VB 2008 Application to study Error Handling. Error Handling.csModule Module1 Sub Main() Dim a As Integer Dim b As Integer = 1 Dim c As Integer = 0 Try a = b c Catch exc As Exception Console.WriteLine("A run-time error occurred") Finally Console.ReadLine() End Try End SubEnd ModuleOm Shanti Engg. College - 2012 28
29. 29. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 29
30. 30. 090360116058 Dot Net Technology PRACTICAL NO: 7AIM: Implement concepts of Inheritance, visual inheritance and Interfacein windows application.Public Interface person Sub setnum(ByVal n1 As Double, ByVal n2 As Double) Function getsum() As DoubleEnd InterfacePublic Class employee Implements person Dim s1 As Double Public Function getsum() As Double Implements person.getsum Return s1 End Function Public Sub setnum(ByVal n1 As Double, ByVal n2 As Double) Implements person.setnum s1 = n1 + n2 End Sub Public Sub substraction(ByVal n1 As Double, ByVal n2 As Double) Dim d3 As Double = n1 - n2 System.console.writeline("The substraction interface is: " & d3) End SubEnd ClassPublic Class demo Inherits employee Public Sub mul(ByVal n1 As Double, ByVal n2 As Double) Dim d3 As Double= n1 * n2 System.Console.WriteLine("The multiplication using inheritance is : " & d3) End SubEnd ClassModule Module1 Sub Main() Dim d As New employee() Dim d5 As New demo() Console.WriteLine("Enter a digit:") Dim d1 As Double = CDbl(Console.ReadLine()) Console.WriteLine("Enter a digit:") Dim d2 As Double = CDbl(Console.ReadLine()) d.setnum(d1, d2) System.Console.WriteLine("The sum using interface is: " & d.getsum) d5.substraction(d1, d2) System.console.writeline() d5.mul(d1, d2) End SubEnd ModuleOm Shanti Engg. College - 2012 30
31. 31. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 31
33. 33. 090360116058 Dot Net Technology cmd = new SqlCommand("Select * from Employee", con); reader = cmd.ExecuteReader(); reader.Close(); con.Close(); } }} XMLReaderusing System;using System.Data;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;namespace WebApplication1{ public partial class assXMLReader : System.Web.UI.Page { DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { ds.ReadXml(Server.MapPath("~/assXML.xml")); } }}Om Shanti Engg. College - 2012 33
34. 34. 090360116058 Dot Net Technology PRACTICAL NO: 9AIM: Use Data Controls like Data List, Grid View, Detail View, Repeaterand List Bound Control .aspx file<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ass14.aspx.cs"Inherits="WebApplication1.ass14" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> </head><body> <form id="form1" runat="server"> <div style="font-weight: 700"><h2>DataList Control</h2> <asp:DataList ID="DataList1" runat="server"> <ItemTemplate> Student name:<%#Eval("Name") %><br />Roll No:<%#Eval("Roll_No") %><br />EmailID:<%#Eval("EmailId") %> </ItemTemplate> <SeparatorTemplate> <hr /> </SeparatorTemplate> <AlternatingItemTemplate> Student name:<%#Eval("Name") %><br />Roll No:<%#Eval("Roll_No") %><br />EmailID:<%#Eval("EmailId") %> </AlternatingItemTemplate> </asp:DataList> <h2>GridView Control</h2> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <br /><h2>DetailsView Control</h2> <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="EmpId" DataSourceID="SqlDataSource1" > <Fields> <asp:BoundField DataField="EmpId" HeaderText="EmpId" ReadOnly="True" SortExpression="EmpId" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Salary" HeaderText="Salary" SortExpression="Salary" /> </Fields> </asp:DetailsView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%\$ ConnectionStrings:db2ConnectionString %>" SelectCommand="SELECT * FROM [Employee]"></asp:SqlDataSource>Om Shanti Engg. College - 2012 34
35. 35. 090360116058 Dot Net Technology <br /><h2>Repeater Control</h2> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table border="1"> <tr> <th>StudName</th> <th>RollNo</th> <th>EmailID</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%#Eval("Name") %></td> <td><%#Eval("Roll_No") %></td> <td><%#Eval("EmailId") %></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> <br /><h2>ListView Control</h2> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> Name:<%#Eval("Name") %><dd>Salary:<%#Eval("Salary") %></dd> </ItemTemplate> </asp:ListView> </div> </form></body></html>Om Shanti Engg. College - 2012 35
36. 36. 090360116058 Dot Net Technology Code Behind Fileusing System;using System.Data;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;namespace WebApplication1{ public partial class ass14 : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=HARDIK-B652B097SQLEXPRESS;Initial Catalog=db1;Integrated Security=True"); SqlDataAdapter adapt; DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { con.Open(); adapt = new SqlDataAdapter("Select * from Student", con); adapt.Fill(ds, "Student"); DataList1.DataSource = ds; DataList1.DataBind(); GridView1.DataSource = ds; GridView1.DataBind(); Repeater1.DataSource = ds; Repeater1.DataBind(); con.Close(); } }}Om Shanti Engg. College - 2012 36
37. 37. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 37
38. 38. 090360116058 Dot Net Technology PRACTICAL NO: 10AIM: Implement web application using ASP.NET with web control. .aspx file<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pizza.aspx.cs" Inherits="WebApplication1.Pizza" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div><h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pizza</h2><br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" AppendDataBoundItems="True" AutoPostBack="True" onselectedindexchanged="CheckBoxList1_SelectedIndexChanged" RepeatColumns="2"> <asp:ListItem>Italian(500)</asp:ListItem> <asp:ListItem>Maxican(1000)</asp:ListItem> <asp:ListItem>Indian(1500)</asp:ListItem> <asp:ListItem>Special(2500)</asp:ListItem> </asp:CheckBoxList> <h2>&nbsp;</h2><h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Toping</h2> <asp:CheckBox ID="CheckBox5" runat="server" Text="Cheez(200/piece)" AutoPostBack="True" /> <asp:CheckBox ID="CheckBox6" runat="server" style="z-index: 1; left: 179px; top: 247px; position: absolute" Text="Butter(15/piece)" AutoPostBack="True" /><br /> <asp:CheckBox ID="CheckBox7" runat="server" Text="Bans(180/piece)" AutoPostBack="True" /> <asp:CheckBox ID="CheckBox8" runat="server" style="z-index: 1; left: 179px; top: 275px; position: absolute" Text="Milk(180/piece)" AutoPostBack="True" /> <br /> <br /> <br /> <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select mode of eating</h2> <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True" GroupName="a" Text="Eat" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True" GroupName="a" Text="Delivery(1000)" />Om Shanti Engg. College - 2012 38
39. 39. 090360116058 Dot Net Technology <br /> <br />&nbsp;<br /> <asp:Button ID="Button1" runat="server" Text="Calculate" onclick="Button1_Click" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </div> </form></body></html> Code Behind Fileusing System;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class Pizza : System.Web.UI.Page { int amt, toping,cnt; protected void Page_Load(object sender, EventArgs e) { } protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { amt = 0; for (int i = 0; i < CheckBoxList1.Items.Count; i++) { if (CheckBoxList1.Items[0].Selected) { cnt += 1; amt += 500; } if (CheckBoxList1.Items[1].Selected) { cnt += 1; amt += 1000; } if (CheckBoxList1.Items[2].Selected) { cnt += 1; amt += 1500; } if (CheckBoxList1.Items[3].Selected) { cnt += 1; amt += 2500; } ViewState["cnt"] = cnt; ViewState["amt"] = amt; } }Om Shanti Engg. College - 2012 39
40. 40. 090360116058 Dot Net Technology protected void Button1_Click(object sender, EventArgs e) { toping = 0; if (CheckBox5.Checked) toping+=(int)ViewState["cnt"]*200; if (CheckBox6.Checked) toping += (int)ViewState["cnt"] * 15; if (CheckBox7.Checked) toping += (int)ViewState["cnt"] * 180; if (CheckBox8.Checked) toping += (int)ViewState["cnt"] * 180; int tot = (int)ViewState["amt"] + toping; if (RadioButton1.Checked) Label1.Text = "Your total bill for pizza is" + tot; } }}Om Shanti Engg. College - 2012 40
41. 41. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 41
42. 42. 090360116058 Dot Net Technology PRACTICAL NO: 11AIM: Write a code for web application to provide input validations usingInput Valuators. .aspx file<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="assVAlidation.aspx.cs"Inherits="WebApplication1.assVAlidation" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <style type="text/css"> .style1 { text-decoration: underline; } </style></head><body> <form id="form1" runat="server"> <div> <strong><span class="style1"><h2>Simple Application Form</h2></span><br class="style1" /> </strong>User Name:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1">Plz enter your name</asp:RequiredFieldValidator> <br /> <br /> Password:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2">Plz enter thepassword</asp:RequiredFieldValidator> <br /> <br /> Retype Password:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator" ControlToCompare="TextBox2" ControlToValidate="TextBox3">Password does not match</asp:CompareValidator> <br /> <br /> E-Mail:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator" ControlToValidate="TextBox4"Om Shanti Engg. College - 2012 42
43. 43. 090360116058 Dot Net Technology ValidationExpression="w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*">Notvalid</asp:RegularExpressionValidator> <br /> <br /> Age:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox> <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TextBox5" MaximumValue="40" MinimumValue="20" Type="Integer">The age should be between 20to 40</asp:RangeValidator> <br /> <br /> Referrer Code:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox6">Try a string that startsfrom 014</asp:CustomValidator> <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Button ID="Button1" runat="server" Text="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Button ID="Button2" runat="server" Text="Cancel" /> &nbsp;</div> </form></body></html>Om Shanti Engg. College - 2012 43
44. 44. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 44
46. 46. 090360116058 Dot Net Technology</body></html> .aspx file<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true"CodeFile="Default2.aspx.cs" Inherits="Default2" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <p> heeeloo world...!!</p> <p> &nbsp;</p> <p> &nbsp;</p> <p> &nbsp;</p> <p>&nbsp;</p> <p>i am back</p></asp:Content>Om Shanti Engg. College - 2012 46
47. 47. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 47
48. 48. 090360116058 Dot Net Technology PRACTICAL NO: 13AIM: Create a Web Application in ASP.NET using various CSS. Cssdemo1(.css file)/* header start */.main_bg{ width:100%; background:url(../images/homebg_header.gif) repeat-x left top; margin:0 auto;}.header_image{width:1003px;height:1153px;background-color:Teal;margin:0 auto;}.bottom_image{width:1003px;height:153px;background-color:Silver;margin:top 153px;} Cssdemo2(.css file)/* general top nav */.top_links{ width:295px; float:right; margin:15px 0 0 0;}.top_links ul{ list-style:none;}.top_links ul li{ float:left; display:block;}.top_links ul li a{ text-decoration:none;Om Shanti Engg. College - 2012 48