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.
090360116058                                                             Dot Net Technology                               ...
090360116058                                               Dot Net Technology        {             int c;             c = ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                   3
090360116058                                             Dot Net Technology                                 Console Calcul...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                   5
090360116058                                                Dot Net Technology                                 Windows Cal...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                   7
090360116058                                                         Dot Net Technology                                 Wi...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                   9
090360116058                                                            Dot Net Technology                                ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  11
090360116058                                                           Dot Net Technology                                 ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  13
090360116058                                                             Dot Net Technology                               ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  15
090360116058                                                         Dot Net Technology                                 Re...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  17
090360116058                                                           Dot Net Technology                                 ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  19
090360116058                                                    Dot Net Technology                                      In...
090360116058                     Dot Net Technology    OUTPUT :Om Shanti Engg. College - 2012                  21
090360116058                                                 Dot Net Technology                                 PRACTICAL ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  23
090360116058                                                      Dot Net Technology                                      ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  25
090360116058                                                               Dot Net Technology                             ...
090360116058                     Dot Net TechnologyOUTPUT :.Om Shanti Engg. College - 2012                  27
090360116058                                                  Dot Net Technology                                 PRACTICAL...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  29
090360116058                                                             Dot Net Technology                               ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  31
090360116058                                                                 Dot Net Technology                           ...
090360116058                                                       Dot Net Technology            cmd = new SqlCommand("Sel...
090360116058                                                               Dot Net Technology                             ...
090360116058                                                            Dot Net Technology    <br /><h2>Repeater Control</...
090360116058                                                              Dot Net Technology                              ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  37
090360116058                                                          Dot Net Technology                                 P...
090360116058                                                                Dot Net Technology     <br />     <br />&nbsp;...
090360116058                                                       Dot Net Technology        protected void Button1_Click(...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  41
090360116058                                                               Dot Net Technology                             ...
090360116058                                                               Dot Net Technology        ValidationExpression=...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  44
090360116058                                                                   Dot Net Technology                         ...
090360116058                                                             Dot Net Technology</body></html>                 ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  47
090360116058                                                             Dot Net Technology                               ...
090360116058                                                                     Dot Net Technology         color:#4E4E4E;...
090360116058                                                                  Dot Net Technology                          ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  51
090360116058                                                                  Dot Net Technology                          ...
090360116058                                                              Dot Net Technology    {            protected voi...
090360116058                                                                Dot Net Technology                            ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  55
090360116058                                                           Dot Net Technology                                 ...
090360116058                                                          Dot Net Technology     <asp:GridView ID="GridView1" ...
090360116058                     Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012                  58
090360116058                                                                     Dot Net Technology                       ...
090360116058                     Dot Net Technology           2) SECURITY           3) APPLICATIONOm Shanti Engg. College ...
090360116058                     Dot Net Technology       4 ) PROVIDEROm Shanti Engg. College - 2012                  61
Upcoming SlideShare
Loading in …5
×

Hems

2,167 views

Published on

  • 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
  26. 26. 090360116058 Dot Net Technology PRACTICAL NO: 5AIM: Implement Windows Form based application using controls likemenus, dialog and tool tip etc.Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load End Sub Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles FileToolStripMenuItem.Click End Sub Private Sub ToolStrip1_ItemClicked(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.ToolStripItemClickedEventArgs) End Sub Private Sub EditToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles EditToolStripMenuItem.Click End Sub Private Sub ProjectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ProjectToolStripMenuItem.Click End Sub Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles HelpToolStripMenuItem.Click End Sub Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles NewToolStripMenuItem.Click End SubEnd ClassOm Shanti Engg. College - 2012 26
  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
  32. 32. 090360116058 Dot Net Technology PRACTICAL NO: 8AIM: Use Dataset, Data Reader, XML Reader & Data Sources (SQL,Object & XML) with Any Windows or Web Application. DataSetusing 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 assDataset : 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 Employee", con); adapt.Fill(ds, "Employee"); con.Close(); } }} DataReaderusing System;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.SqlClient;namespace WebApplication1{ public partial class assrreader : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=HARDIK-B652B097SQLEXPRESS;Initial Catalog=db2;Integrated Security=True"); SqlCommand cmd; SqlDataReader reader; String str; protected void Page_Load(object sender, EventArgs e) { con.Open();Om Shanti Engg. College - 2012 32
  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
  45. 45. 090360116058 Dot Net Technology PRACTICAL NO: 12AIM: Create a Web application that illustrates the use of themes andmaster pages with Site-Map. Main.master<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main"%><!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"> <center> <table cellpadding="0" cellspacing="0" style="width:1000px; border: 1px solid black;"> <tr> <td colspan="3" style="height:180px; background-color:Silver; width:1000px; border:1px solidblack;" ></td> </tr> <tr> <td colspan="3" style="height:35px; background-color:Gray; width:1000px; border:1px solidblack;" > <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"> <Items> <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem> <asp:MenuItem Text="About Us" Value="About Us"></asp:MenuItem> <asp:MenuItem Text="Contact Us" Value="Contact Us"></asp:MenuItem> <asp:MenuItem Text="Services" Value="Services"></asp:MenuItem> </Items> </asp:Menu> </td> </tr> <tr style="width:1000px;"> <td style="width:200px; background-color:Green; height:850px;">&nbsp;</td> <td style="width:550px; background-color:Green; height:850px;"> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </td> <td style="width:250px;background-color:Green; height:850px;">&nbsp;</td> </tr> <tr> <td colspan="3" style="height:20px; width:1000px;background-color:Black;"></td> </tr> </table> </center> </form>Om Shanti Engg. College - 2012 45
  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
  49. 49. 090360116058 Dot Net Technology color:#4E4E4E; padding:0 10px 0 10px; font-size:12px;}.top_links ul li a:hover{ text-decoration:none; color:#8B8B8B;}.nav { float:right; width:550px; padding:23px 0 0 0; display:block;} .aspx file<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cssdemo.aspx.cs"Inherits="cssdemo" %><!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>css demo</title> <link href="css/cssdemo1.css" rel="stylesheet" type="text/css" /> <link href="css/cssdemo2.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"><div class="header_image"><div class="bottom_image"> <div class="header"> This is header part.... <div class="top_links"> <ul class="style3" dir="ltr" type="disc"> <li> <div class="menu_list"> <ul> <li> <a href="#">languages<img src="images/arrow-bullet.gif" alt="global list"width="8" height="4" /> </li> </a> <!--<![endif]--> <!--[if lte IE 6]><table cellpadding="0" cellspacing="0"border="0"><tr><td><![endif]--> <ul> <li><a target="_blank"href="http://www.freedomdesigns.in">INDIA</a></li>Om Shanti Engg. College - 2012 49
  50. 50. 090360116058 Dot Net Technology <li><a target="_blank" href="http://www.freedomdesigns.in">UK</a></li> </ul> </div> </li> </ul> <br /> </form></body></html>Om Shanti Engg. College - 2012 50
  51. 51. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 51
  52. 52. 090360116058 Dot Net Technology PRACTICAL NO: 14AIM: Implement the concept of state management in a web application. .asax file(Global Application file)using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Security;using System.Web.SessionState;namespace WebApplication1{ public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { Application["count"] = 0; } protected void Session_Start(object sender, EventArgs e) { } protected void Application_BeginRequest(object sender, EventArgs e) { } protected void Application_AuthenticateRequest(object sender, EventArgs e) { } protected void Application_Error(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected void Application_End(object sender, EventArgs e) { } }} .aspx fileusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class WebForm3 : System.Web.UI.PageOm Shanti Engg. College - 2012 52
  53. 53. 090360116058 Dot Net Technology { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Application.Lock(); Application["count"] = (int)Application["count"] + 1; Response.Write("Visitor No.=" + Application["count"]); Application.UnLock(); } } protected void Button1_Click(object sender, EventArgs e) { Session["name"] = TextBox1.Text; Session["pwd"] = TextBox2.Text; Response.Redirect("NextPage.aspx"); } }} Code Behind Fileusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Application.Lock(); Application["count"] = (int)Application["count"] + 1; Response.Write("Visitor No.=" + Application["count"]); Application.UnLock(); } } protected void Button1_Click(object sender, EventArgs e) { Session["name"] = TextBox1.Text; Session["pwd"] = TextBox2.Text; Response.Redirect("NextPage.aspx"); } }}Om Shanti Engg. College - 2012 53
  54. 54. 090360116058 Dot Net Technology NextPage.aspx.csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class NextPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write("Welcome " + Session["name"] + ". Your password is " + Session["pwd"]); } }}Om Shanti Engg. College - 2012 54
  55. 55. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 55
  56. 56. 090360116058 Dot Net Technology PRACTICAL NO: 15AIM: Implement code in ASP.NET that creates and consumes Web service. .asmx file(WebService)using System;using System.Data;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using System.Data.SqlClient;namespace WebApplication1{ [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class assWebServic : System.Web.Services.WebService { SqlConnection con=new SqlConnection("Data Source=HARDIK-B652B097SQLEXPRESS;Initial Catalog=db1;Integrated Security=True"); SqlDataAdapter adapt; DataSet ds=new DataSet(); [WebMethod] public DataSet show() { con.Open(); adapt = new SqlDataAdapter("Select * from Student", con); adapt.Fill(ds, "Student"); con.Close(); return ds; } }} .aspx file<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="assWebServic.aspx.cs"Inherits="WebApplication1.assWebServic1" %><!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>Om Shanti Engg. College - 2012 56
  57. 57. 090360116058 Dot Net Technology <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form></body></html> Code Behind Fileusing System;using System.Data;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class assWebServic1 : System.Web.UI.Page { DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { localhost1.assWebServic obj = new localhost1.assWebServic(); ds=obj.show(); GridView1.DataSource = ds; GridView1.DataBind(); } }}Om Shanti Engg. College - 2012 57
  58. 58. 090360116058 Dot Net TechnologyOUTPUT :Om Shanti Engg. College - 2012 58
  59. 59. 090360116058 Dot Net Technology PRACTICAL NO: 16AIM: Study of ASP.NET administration and configuration tool. The Web Site Administration Tool is used to configure the application and security settings ofan ASP.NET Web Application. We can use this tool to perform following tasks:  Configuring the application security settings, such as authentication and authorization.  Managing users and roles for an application.  Creating and managing application settings.  Configuring SMTP email settings.  Making an application temporarily offline to update its content and data in a secure manner.  Adjusting the debugging and tracing settings.  Defining a default custom error page.  Selecting providers to use them with the site features, such as membership. STEPS TO WEBSITE ADMINISTRATION TOOL: 1) HOMEOm Shanti Engg. College - 2012 59
  60. 60. 090360116058 Dot Net Technology 2) SECURITY 3) APPLICATIONOm Shanti Engg. College - 2012 60
  61. 61. 090360116058 Dot Net Technology 4 ) PROVIDEROm Shanti Engg. College - 2012 61

×