Dot Net Programs

86
Name: Tanmay Baid Roll Number: 0829cs071112 List of Programs: 1. WAP to print “HELLO C#” 3 2. WAP to read two integer numbers and print the sum 6 3. WAP to input and output 5 numbers using array and function 8 4. WAP using 2D array to print a matrices 10 5. WAP to print jagged array and also find the number of rows and number of columns in each row 12 6. WAP to find sum of two number using function 14 7. WAP to show how static data member works in a class 16 8. WAP to check whether the two entered string are equal or not using string class and its methods. also find the length of each string 18 9. WAP to show how we can use structure in a class 20 10. WAP to show how structure variable works differently than class variable (object) 22 11. WAP to show how we can pass object as an argument to a function 24 1

description

Solution of some general dot net programs

Transcript of Dot Net Programs

Page 1: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

List of Programs:1. WAP to print “HELLO C#”

32. WAP to read two integer numbers and print the sum

63. WAP to input and output 5 numbers using array and function

84. WAP using 2D array to print a matrices

105. WAP to print jagged array and also find the number of rows

and number of columns in each row 12

6. WAP to find sum of two number using function 14

7. WAP to show how static data member works in a class 16

8. WAP to check whether the two entered string are equal or not using string class and its methods. also find the length of each string 18

9. WAP to show how we can use structure in a class 20

10. WAP to show how structure variable works differently than class variable (object) 22

11. WAP to show how we can pass object as an argument to a function 24

12. WAP that will work like copy constructor of c++ 26

13. WAP that contains different classes but no inheritance 28

14. WAP to inherit base class into derived class (no method overriding) 30

1

Page 2: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

15. WAP to show polymorphism using virtual and override keyword 33

16. WAP to show how we can use abstract class and abstract method 36

17. WAP to show multiple inheritance using class and interface 38

18. WAP to avoid inheritance of particular method 40

19. WAP to show how we can use enumeration to define symbolic constants for color 41

20. WAP to show how we can use enumeration to define symbolic constants for on/off (1,0) values 43

21. WAP to print name and surname from command line. 42

22. WAP to find sum and average of n numbers entered by user using foreach loop.

4723. Create a Windows form to calculate compound interest

and print the result on message box. 49

24. Create a windows form to show stored data in sql server database on form using GridView control.

5125. Create a windows form to insert student information in

table named “STU”. 53

2

Page 3: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

26. Create a windows MDI form, add Menu on it and link it to various dialogs, forms.

5527. Create HTML form using notepad and print “Hello Html”

in explore. 5828. Create an asp.net page to show use of various standard

controls. 6029. Create an asp.net page for new registration and insert

record in sql database. Show the inserted records on another page. 61

30. Create an asp.net page to show use of various validation controls. 63

31. Create an asp.net page to display random image using AdRotator control and XML file.

6432. Create an asp.net page to show use of Web User

Control. 6633. Create an asp.net page to allow update, edit, delete

option on GridView control. 68

34. Create and apply .css(Cascading Style Sheet) file. 69

35. Create and apply .skin (Theme) file. 71

3

Page 4: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

// 1. WAP to print “HELLO C#”

using System;using System.Collections.Generic;using System.Text;

namespace printname{ class Program { static void Main(string[] args) { Console.WriteLine("HELLO C#"); Console.ReadLine(); } }}

4

Page 5: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

5

Page 6: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

// 2. WAP to read two integer numbers and print the sum

using System;using System.Collections.Generic;using System.Text;

namespace ConsoleApplication3{ class Program { static void Main(string[] args) { Console.WriteLine("Enter the first number:"); string s1 = Console.ReadLine(); int a1 = Convert.ToInt32(s1); Console.WriteLine("Enter the second number:"); string s2 = Console.ReadLine(); int a2 = Convert.ToInt32(s2); int s3 = a1 + a2; Console.WriteLine("The sum is:" + s3); Console.ReadLine(); } }}

6

Page 7: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

7

Page 8: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

// 3. WAP to input and output 5 numbers using array and function

using System;using System.Collections.Generic;using System.Text;

namespace ConsoleApplication{ class Array { static void Main(string[] args) { int[] a = new int[5];

GetArray(a); Console.WriteLine("ENTERED NUMBER IS\n"); for (int i = 0; i < a.Length; i++) Console.WriteLine("a[" + i + "]=" + a[i]); Console.ReadLine(); } static void GetArray(int[] a) {

Console.WriteLine("ENTER 5 NUMBERS"); for (int i = 0; i < a.Length; i++)

a[i] = int.Parse(Console.ReadLine()); }

}}

8

Page 9: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

9

Page 10: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

// 4. WAP using 2D array to print a matrices.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication6{ class TwoDArray { static void Main(string[] args) { int[,] a; a = new int[2, 3]; a[0, 0] = 50; a[0, 1] = 60; a[0, 2] = 70; a[1, 0] = 80; a[1, 1] = 90; a[1, 2] = 100; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) Console.Write(" " + a[i, j]); Console.WriteLine(); } Console.WriteLine("press any key to exit"); Console.ReadLine(); } }}

10

Page 11: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

11

Page 12: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112/* 5. WAP to print jagged array and also find the number of rows and number of columns in each row.*/

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication7{ class Demo { static void Main(string[] args) { int[][] a = new int[2][]; a[0] = new int[] { 89,94,46,54,64 }; a[1] = new int[] {12,56}; for (int i = 0; i < a.Length; i++) { for (int j = 0; j < a[i].Length;j++) Console.Write(" " + a[i][j]); Console.WriteLine(); } Console.WriteLine("no of rows=" +a.Length); Console.WriteLine("no of column in first row=" + a[0].Length); Console.WriteLine("no of column in second row=" + a[1].Length); Console.WriteLine("\npress any key to exit"); Console.ReadLine(); } }}

12

Page 13: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

13

Page 14: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 6. WAP to find sum of two number using function.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication8{ class Sumof { static void Main(string[] args) { int a, b; Console.Write("Enter 1st Number "); a = int.Parse(Console.ReadLine()); Console.Write("Enter 2nd Number "); b = int.Parse(Console.ReadLine()); int c = sum(a, b); Console.WriteLine("Sum of " + a + " & " + b + " is =" + c); Console.ReadLine(); } static int sum(int a, int b) { int c = a + b; return c; } }}

14

Page 15: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

15

Page 16: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 7. WAP to show how static data member works in a class.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication9{ class A { static int n; public void Get(int x) { n = x; } public void Show() { Console.WriteLine("n=" + n); }

} class sta_tic { static void Main() { A a = new A(); a.Get(99); a.Show(); A b = new A(); b.Get(200); b.Show(); a.Show(); Console.ReadLine(); } }}

16

Page 17: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

17

Page 18: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112/*8. WAP to check whether the two entered string are equal or not using string class and its methods. also find the length of each string.*/

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication10{ class Demo { public static void Main(string[] args) { string s = "Check"; string t = "Check"; if (s.Equals(t)) Console.WriteLine("Strings are Same"); else Console.WriteLine("String are Different"); Console.WriteLine("Length of the string s is= " + s.Length); Console.ReadLine(); } }}

18

Page 19: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

19

Page 20: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 // 9. WAP to show how we can use structure in a class.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication11{ struct Student { int rollno; string name; public void SetData(int r, string n) { rollno = r; name = n; } public void ShowData() { Console.WriteLine("ROLL NO=:" + rollno);

Console.WriteLine("Name=:" + name); }

} class struc { static void Main(string[] args) { Student s = new Student(); s.SetData(52, "Tanmay Baid"); s.ShowData(); Console.ReadLine(); } }}

20

Page 21: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

21

Page 22: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 10. WAP to show how structure variable works differently than class variable (object).

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication12{ struct Student { int rollno; string name; public void SetData(int r, string n) { rollno = r; name = n; } public void ShowData() { Console.WriteLine(rollno + " " + name); } } class strt { static void Main(string[] args) { Student s = new Student(); s.SetData(1, "Enrique"); s.ShowData(); Student t = s; // values of s will be copied into t t.ShowData(); t.SetData(2, "Atif"); // s will not change t.ShowData(); s.ShowData(); Console.ReadLine(); } }}

22

Page 23: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

23

Page 24: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 11. WAP to show how we can pass object as an argument to a function.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication13{ class Student { int rollno; string name; public void SetData(int r, string n) { rollno = r; name = n; } public void ShowData() { Console.WriteLine(rollno + " " + name); } public void SetData(Student a) { rollno = a.rollno; name = a.name; } } class Demo { static void Main(string[] args) { Student s = new Student(); s.SetData(1, "Shirlee"); s.ShowData(); Student t = new Student(); t.SetData(s); t.ShowData(); t.SetData(2, "Robin"); // s will not change t.ShowData(); s.ShowData(); Console.ReadLine(); } }}

24

Page 25: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

25

Page 26: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 12. WAP that will work like copy constructor of c++.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication14{ class Student { int rollno; string name;

public void SetData(int r, string n) { rollno = r; name = n; } public void ShowData() { Console.WriteLine(rollno + " " + name); } } class Demo { static void Main(string[] args) { Student s = new Student(); s.SetData(1, "Gabriel"); s.ShowData(); Student t = s;// t will point to s t.ShowData(); t.SetData(2, "Rohinton");// s will also be changed

t.ShowData();s.ShowData();

Console.ReadLine(); } }}

26

Page 27: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

27

Page 28: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 13. WAP that contains different classes but no inheritance.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication15{ class A { public void Show() { Console.WriteLine("Show A"); } } class B { public void Show() { Console.WriteLine("Show B"); } } class Demo { static void Main(string[] args) { A a = new A(); a.Show(); B b = new B(); b.Show(); Console.ReadLine(); } }}

28

Page 29: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

29

Page 30: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 14. WAP to inherit base class into derived class (no method overriding).

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication16{ class A { public void Say() { Console.WriteLine("say A"); } public void Write() { Console.WriteLine("write A"); } } class B : A { public void Say() { Console.WriteLine("say B"); } public void Call() { Console.WriteLine("Call B"); } } class Demo { static void Main(string[] args) { A a = new A(); Console.WriteLine("Langston Hughes"); a.Say(); a.Write(); //a.call(); // call() not accessible by A's abject Console.WriteLine("*Octavia Butler"); B b = new B(); b.Say(); b.Write(); b.Call(); Console.WriteLine("--when (a=b)--"); a = b;

30

Page 31: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 a.Say(); a.Write(); // a.Call(); // we cant call call() bcozz it is not defined by A class Console.ReadLine(); } }}

31

Page 32: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

32

Page 33: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 15. WAP to show polymorphism using virtual and override keyword .

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication17{ class A { public virtual void Show() { Console.WriteLine("Show A"); } public virtual void Fun() { Console.WriteLine("Fun A"); } } class B : A { public override void Show() { Console.WriteLine("Show B"); } public void Call() { Console.WriteLine("Call B"); } } class Demo { static void Main(string[] args) { A a = new A(); Console.WriteLine("***X***"); a.Show(); a.Fun(); //a.Call(); // call() not accessible by A's abject B b = new B(); Console.WriteLine("***Y***"); b.Show(); b.Fun(); b.Call(); a = b; Console.WriteLine("***when(a=b)***");

33

Page 34: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 a.Show(); a.Fun(); // a.Call(); // we cant call call() bcozz it is not defined by A class Console.ReadLine(); } }}

34

Page 35: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

35

Page 36: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 16. WAP to show how we can use abstract class and abstract method.using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication18{ abstract class A { public virtual void Show() { Console.WriteLine("Show A"); } public virtual void Fun() { Console.WriteLine("Fun A"); } public abstract void Call(); } class B : A { public override void Show() { Console.WriteLine("Show B"); } public override void Call() { Console.WriteLine("Call B"); } } class Demo { static void Main(string[] args) { B b = new B(); Console.WriteLine("----B----"); b.Show(); b.Fun(); b.Call(); A a = b; Console.WriteLine("----(A=B)----"); a.Show(); a.Fun(); a.Call(); Console.ReadLine(); }

36

Page 37: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 }}

Output:

37

Page 38: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 17. WAP to show multiple inheritance using class and interface.using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication19{ class A { public virtual void Show() { Console.WriteLine("Show A"); } public void Disp() { } } interface Z { void Call(); } class B : A, Z { public override void Show() { Console.WriteLine("Show B"); } public void Call() { Console.WriteLine("Call B"); } } class Demo { static void Main(string[] args) { B b = new B(); Console.WriteLine("----B---"); b.Show(); // will call show() of B class b.Call(); // will call call() of B class A a = b; Console.WriteLine("---(A=B)--"); a.Show(); // will call show() of B class Console.ReadLine(); } }}

38

Page 39: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

39

Page 40: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112// 18. WAP to avoid inheritance of particular method.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication20{ class A { public virtual void Show() { Console.WriteLine("Show A"); } } class B : A { public sealed override void Show() { Console.WriteLine("Show B"); } } class C : B { public override void Show() // Error :sealed method in B cant be override { Console.WriteLine("Show B"); } } class Demo { static void Main(string[] args) { B b = new B();

A a = b; a.Show(); Console.ReadLine(); } }}

40

Page 41: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

// 19. WAP to show how we can use enumeration to define symbolic constants for color.

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication21{ class Colors { enum Color { Voilet, Green, Blue, } static void Main(string[] args) { string buffer; Color myColor; Console.WriteLine("Violet=0"); Console.WriteLine("Green=1"); Console.WriteLine("Blue=2"); Console.WriteLine("Enter a value for a color:"); buffer = Console.ReadLine(); myColor = (Color)Convert.ToInt32(buffer);

switch (myColor) { case Color.Voilet: System.Console.WriteLine("\nYour choise of colour is:..."); break; case Color.Green: System.Console.WriteLine("\nYour choise of colour is..."); break; case Color.Blue: System.Console.WriteLine("\nYour choise of colour is..."); break; default: System.Console.WriteLine("\nYour choise of colour is..."); break; }

41

Page 42: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 System.Console.WriteLine("\n {0} ({1})", myColor, (int)myColor); Console.WriteLine("thanks!!"); Console.Read(); } }}

Output:

Output for Blue:

Output for Green:

42

Page 43: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 20. WAP to show how we can use enumeration to define symbolic constants for on/off (1,0) values.*/

using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication22{ class TTT { public enum Mode { off, on } static void Main(string[] args) { Mode ob; Console.WriteLine("enter 0 or 1"); string str = Console.ReadLine(); ob = (Mode)Convert.ToByte(str);

if (ob == Mode.off) Console.WriteLine("off");

43

Page 44: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 else if (ob == Mode.on) Console.WriteLine("on"); else Console.WriteLine("invalid number"); Console.ReadLine(); } }}

Output:

Output for ON Condition:

44

Page 45: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output for OFF Condition:

/* 21. WAP to print name and surname from command line.*/

45

Page 46: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

46

Page 47: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 22. WAP to find sum and average of n numbers entered by user using foreach loop.*/

using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace ConsoleApplication24{ class Program { static void Main(string[] args) { int n, y; float sum = 0; float avg;

47

Page 48: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 Console.WriteLine("Enter value of n: "); String no = Console.ReadLine(); n = Convert.ToInt32(no); int[] nums = new int[n]; Console.WriteLine("Enter value in array: "); for (int i = 0; i < n; i++) {

Console.WriteLine("Enter value: "); String z = Console.ReadLine(); y = Convert.ToInt32(z);

nums[i] = y; } foreach (int x in nums) { Console.WriteLine("Value is: " + x); sum = sum + x; } Console.WriteLine("Summation is: " + sum); avg = sum / n; Console.WriteLine("Avreage is: " + avg); Console.ReadLine(); } }}

Output:

48

Page 49: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 23. Create a Windows form to calculate compound interest and print the result on message box.*/

49

Page 50: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

using 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 WindowsFormsApplication8{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) {

}

private void button1_Click(object sender, EventArgs e) { int p, t, r, si; { p = Convert.ToInt32(textBox1.Text); r = Convert.ToInt32(textBox2.Text); t = Convert.ToInt32(textBox3.Text); si = (p * t * r) / 100; MessageBox.Show("Interest is"+si); } } }}

50

Page 51: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

51

Page 52: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 24. Create a windows form to show stored data in sql server database on form using GridView control.*/

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;

namespace WindowsFormsshowdataGridview{ public partial class Form1 : Form { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Atif;Integrated Security=True;Pooling=False"); SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet(); public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) {

}

private void button1_Click(object sender, EventArgs e) { ds.Clear(); string str = "select * from Employ"; da = new SqlDataAdapter(str, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0];

} }}

52

Page 53: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

53

Page 54: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 25. Create a windows form to insert student information in table named “STU”.*/

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace stuinformation{ public partial class Form1 : Form { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Atif;Integrated Security=True;Pooling=False"); SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet(); SqlCommandBuilder cmb; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e){ } private void Insert_Click(object sender, EventArgs e) { ds.Clear(); string str = "Select * from Stu"; SqlDataAdapter da = new SqlDataAdapter(str, con); da.Fill(ds); cmb = new SqlCommandBuilder(da); DataRow dr = ds.Tables[0].NewRow(); dr[0] = textBox1.Text; dr[1] = textBox2.Text; dr[2] = textBox6.Text;

54

Page 55: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 dr[3] = textBox3.Text; dr[4] = textBox4.Text; dr[5] = textBox5.Text; ds.Tables[0].Rows.Add(dr); da.Update(ds); MessageBox.Show("Record insert"); } }}

Output:

55

Page 56: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 26. Create a windows MDI form, add Menu on it and link it to various dialogs, forms.*/

using 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 WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void editToolStripMenuItem_Click(object sender, EventArgs e) {

}

private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK)

56

Page 57: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112 { string FileName = openFileDialog.FileName; } }

private void newToolStripMenuItem_Click(object sender, EventArgs e) {

Form2 f = new Form2(); f.MdiParent = this; f.Show(); }

private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = saveFileDialog.FileName; } }

private void solutionToolStripMenuItem_Click(object sender, EventArgs e) {

}

private void newWindowToolStripMenuItem_Click(object sender, EventArgs e) { Form2 childForm = new Form2(); childForm.MdiParent = this; childForm.Text = "Window " + childFormNumber++; childForm.Show(); } }}

57

Page 58: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

58

Page 59: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 27. Create HTML form using notepad and print “Hello Html” in explore.*/

59

Page 60: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

60

Page 61: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 28. Create an asp.net page to show use of various standard controls.*/

61

Page 62: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 29. Create an asp.net page for new registration and insert record in sql database. Show the inserted records on another page.*/

62

Page 63: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Atif;Integrated Security=True;Pooling=False"); SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet();

protected void Page_Load(object sender, EventArgs e) {

} protected void Button1_Click(object sender, EventArgs e) { string str="insert into Registation values('"+TextBox1 .Text +"','"+TextBox2 .Text +"','"+TextBox3 .Text +"','"+TextBox4 .Text +"','"+TextBox5 .Text +"','"+TextBox6 .Text +"','"+TextBox7 .Text +"')"; SqlCommand cmd = new SqlCommand(str, con); cmd .Connection .Open (); cmd .ExecuteNonQuery (); cmd .Connection .Close (); Response.Write("Record insert");

}}

63

Page 64: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

64

Page 65: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 30. Create an asp.net page to show use of various validation controls.*/

65

Page 66: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 31. Create an asp.net page to display random image using AdRotator control and XML file.*/

<?xml version="1.0" encoding="utf-8" ?><Advertisements> <Ad> <ImageUrl>1317.jpg</ImageUrl>

<navigateUrl>http//www.yahoo.com</navigateUrl> <Alternatetext>adsfdgfgf</Alternatetext>

</Ad> <Ad> <ImageUrl>Lithia Park, Ashland, Oregon - 1600x1200 - ID 12.jpg</ImageUrl>

<navigateUrl>http//www.yahoo.com</navigateUrl> <Alternatetext>adsfdgfgf</Alternatetext>

</Ad>

</Advertisements>

66

Page 67: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

67

Page 68: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 32. Create an asp.net page to show use of Web User Control.*/

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register TagPrefix ="CS" TagName ="P1" Src ="~/WebUserControl.ascx" %><!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>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <CS:P1 ID="as" runat="server" /> </div> </form></body></html>

68

Page 69: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

69

Page 70: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 33. Create an asp.net page to allow update, edit, delete option on GridView control.*/

70

Page 71: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 34. Create and apply .css(Cascading Style Sheet) file.*/

body, td, th{ font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif;

background-color: gray;}body {

margin-left: 50px;margin-top: 50px;margin-right: 10px;margin-bottom: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px; color:#000000;}

A:link{

color: Blue;text-decoration: none;

}

71

Page 72: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112A:visited {

text-decoration: none;color:Pink;}

A:active {text-decoration: none;color:Black;}

A:hover {text-decoration: underline;color:white;}

BUTTON{

font-size: 9pt;color: white;font-family: 'Book Antiqua' , Verdana;background-color: #7f5f72;

}

Output:

72

Page 73: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

/* 35. Create and apply .skin (Theme) file.*/

73

Page 74: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112<%--Default skin template. The following skins are provided as examples only.1. Named control skin. The SkinId should be uniquely defined because duplicate SkinId's per control type are not allowed in the same theme.<asp:GridView runat="server" SkinId="gridviewSkin" BackColor="White" > <AlternatingRowStyle BackColor="Blue" /></asp:GridView>2. Default skin. The SkinId is not defined. Only one default control skin per control type is allowed in the same theme.<asp:Image runat="server" ImageUrl="~/images/image1.jpg" />--%><asp:TextBoxBordercolor="Blue"backcolor="Pink"runat="server"/><asp:ButtonBordercolor="Black"backcolor="Yellow"runat="server"/>

74

Page 75: Dot Net Programs

Name: Tanmay Baid Roll Number: 0829cs071112

Output:

75