all

Practical No:
Date:
1.
Working with Basic C# and ASP.NET
1(a). create an application that obtain four int values from the users and displays the product.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical_1a
public partial class Multiplication : System.Web.UI.Page
protected void Button1_Click(object sender, EventArgs e)
int numi, num2, num3, num4, prod;
num1 = Convert.ToInt32(TextBox1.Text); num2 = Convert.ToInt32(TextBox2.Text); num3 = Convert.ToInt32(TextBox3.Text); num4 = Convert.ToInt32(TextBox4.Text);
prod = num1 * num2 * num3 * num4;
TextBox5.Text = Convert.ToString(prod);
Smt.Janakibai Rama Salvi College Kalwa(W Page 1
Practical No:
Date:
localhost:50014/Multiplication.as X
€ → !! Apps
c D
O localhost:50014/Multiplication.aspx A page can have only
240
Multiply
Smt.Janakibai Rama Salvi College Kalwa(WPage 2
Practical No:
Date:
1(b). Create an application to demonstrate string operations.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class String_Operations : System.Web.UI. Page
protected void Button1_Click(object sender, EventArgs e)
string str1 = TextBox1.Text;
string[] words = stri.Split();
for(int i=0;i<words.Length; i++)
TextBox2.Text =TextBox2.Text+words[i]+"\n\r";
Smt.Janakibai Rama Salvi College Kalwa(WPage 3
Practical No:
Date:
O localhost:50127/WebSite5/String x
+
→ C Apps
localhost:50127/WebSite5/String Operations.aspx A page can have only
i am a boy
Button
Smt.Janakibai Rama Salvi College Kalwa(WPage 4
Practical No:
Date:
1(c). Create an application that receive the (Student Id, Student Name, Course Name, Date of Birth) information from a set of students. The application should also dislplay the information of all the students once the data entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
struct Student
public string studid, name, chame;
public string dob;
public partial class Student_Information : System.Web.UI. Page
Student[] s = new Student[1];
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
int i;
Smt.Janakibai Rama Salvi College Kalwa(WPage 5
Practical No:
Date:
for (i = 0; i < 1; i++)
s[i].studid = TextBox2.Text;
s[i].name = TextBox3. Text;
s[i].chame = TextBox4.Text; s[i].dob = TextBox5.Text;
for (i = 0; i < 1; i++)
Response.Write("\nStudent ID:" + s[i].studid+"<br>"); Response.Write("\nStudent name:" + s[i].name + "<br>"); Response.Write("\nCourse name:" + s[i].chame + "<br>"); Response.Write("\nDate of Birth(dd-mm-yy):" + s[i].dob + "<br>");
S
Response.Write("<br>");
Response.Write("<br>");
Smt.Janakibai Rama Salvi College Kalwa(WPage 6
1.(d) Create an application to demonstrate following operations.
(i) Generate Fibonacci series.
Practical No:
Date:
Smt.Janakibai Rama Salvi College Kalwa(WPage 9
(ii) Test for prime numbers.
Practical No:
Date:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Prime_Number : System.Web.UI. Page
protected void Button1_Click(object sender, EventArgs e)
{
int n, i, C;
n = int.Parse(TextBox1.Text);
for (c = 2; < <= n; c++)
if ((n % c) == 0)
break;
if (n == 1)
Response.Write(n + " is neither prime nor composite");
else if (c < n - 1)
Response.Write(n + " is not prime number");
else
Response.Write(n + "is prime number");
} }
Smt.Janakibai Rama Salvi College Kalwa(W)Page 11
(iii) Test for vowels.
Practical No:
Date:
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Vowels_Check : System.Web.UI. Page
{
protected void Button1_Click(object sender, EventArgs e)
String ch;
int count = 0;
ch = TextBox1.Text;
for (int i = 0; i < ch.Length; i++)
if ((ch. Substring(i, 1) == "a") || (ch. Substring(i, 1) == "e") ||| (ch. Substring(i, 1) == "i") || (ch. Substring(i, 1) == "0") || (ch. Substring(i, 1) ==
count++;
en
Response.Write("Given String: \n" + ch+"<br>"); Response.Write("Total Number of vowels:\n" + count+"<br>");
Response.Write("<br>");
Response.Write("<br>");
Smt.Janakibai Rama Salvi College Kalwa(W)Page 13
Practical No:
Date:
localhost:50377/WebSite10/Vowe X
+
+
+ C Apps
o localhost:50377 /WebSite 10 Nowels Check, aspx A page can have only
Given String: This is a vowel example Total Number of vowels: 8
Enter a String: This is a vowel example
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 14
(iv) Use foreach loop with arrays.
Practical No:
Date:
int[] a = { 1, 2, 3, 4 };
foreach (int x in a)
Response.Write(x);
localhost:50593/WebSite11/forea *
+
e
o localhost:50593/WebSite11/foreach_loop.aspx A page can have only
* Apps
1234
Button
Smt.Janakibai Rama Salvi College Kalwa(WPage 16
(v). Reverse a number and find sum of digits of a number.
Practical No:
Date:
revnum = revnum * 10 + digit;
sumDigits = sumDigits + digit;
num = num / 10;
Response.Write("Reverse of\n" + actualnumber + "=" + revnum+"<br>");
Response.Write("sum of its digits:\n" + sumDigits + "<br>");
Smt.Janakibai Rama Salvi College Kalwa(W)Page 18
Practical No:
Date:
localhost:50669/reverseNumber/ x
+
6
C
O localhost: 50669/reverse Number/Reverse Number.aspx
Apps
A page can have only
Reverse of 154=451 sum of its digits: 10 Enter a digits 154
Reverse
Smt.Janakibai Rama Salvi College Kalwa(W)Page 19
2. Working With Object Oriented C# And ASP.NET.
2(a) Create simple application to perform follwoing operations.
(i) Finding factorial Value.
(ii) Money Conversion.
Practical No:
Date:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class classi
public double r, e, d;
public class1()
r = 0; e = 0; d = 0;
public void convertdtor()
double ev = 60;
r = d * ev;
public void convertetor()
double ev = 80;
r =
e * ev;
public void convertrtod()
double ev = 65;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 22
Practical No:
Date:
d = r / ev;
public void convertrtoe()
double ev = 80;
e = r / ev;
public partial class Currency_Converter ; System.Web.UI. Page
Class1 f1;
protected void Page_Load(object sender, EventArgs e)
f1 = new Class1();
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton2.Checked == true)
{
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtod();
Response.Write(f1.r + "Rupee" + "$" + f1.d);
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
Smt.Janakibai Rama Salvi College Kalwa(W)Page 23
Practical No:
Date:
if (RadioButton1. Checked == true)
f1.d = Convert.ToInt16(TextBox1.Text);
f1.convertdtor();
Response.Write(f1.d + "Dollar" + "=Rs." + f1.r);
protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton3. Checked == true)
f1.e = Convert.ToInt16(TextBox1.Text);
f1.convertetor();
Response.Write(f1.e + "Euro" + "=Rs." + f1.r);
protected void RadioButton4_CheckedChanged(object sender, EventArgs e)
if (RadioButton4.Checked == true)
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtoe();
Response.Write(f1.r + "=Rs. to Euro" + f1.e);
Smt.Janakibai Rama Salvi College Kalwa(W)Page 24
Practical No:
Date:
Smt.Janakibai Rama Salvi College Kalwa(WPage 25
(iii) Quadratic Equation
Practical No:
Date:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; class Quadraticroots
public double a, b, c, r1, r2; public double compute()
int m; double d1; d1 = b * b - 4 * a * c; if (d1 == 0)
*
r1 = r2 = (-b) / (2 * a); return d1;
else if (d1 > 0)
r1 = (-b + Math.sqrt(di)) / (2 * a); r2 = (-b - Math.Sqrt(01)) I (2 * a); return d1;
else
r1 = (-b) / (2 * a); r2 = Math.Sqrt(-d1) / (2 * a); return d1;
namespace practical
public partial class Qudratic_equation : System.Web.UI.Page
Quadraticroots q;
protected void Page_Load(object sender, EventArgs e)
q = new Quadraticroots();
protected void Button1_Click(object sender, EventArgs e)
Smt.Janakibai Rama Salvi College Kalwa(W)Page 27
Practical No:
Date:
q.a = Convert.ToInt16(TextBox1.Text); q.b = Convert.ToInt16(TextBox2.Text); q.c = Convert.ToInt16(TextBox3.Text); double d = a.compute(); if (d == 0)
Response.Write("\n Roots are real and Equal<br>"); Response.Write("First root and second root is" + q.r1);
else if (d > 0)
{
Response.Write("\nRoots are real and Distinct<br>"); Response.Write("\nFirst Root is" + q.r1 + "<br>"); Response.Write("\nSecond Root is" + q.r2 + "<br>");
else
Response.Write("\nRoots are Imaginary <br>"); Response.Write("\nFirst Roots is"+q.r1+"<br>");
Response.Write("\nSecond Roots is"+q.r2+"<br>");
Smt.Janakibai Rama Salvi College Kalwa(W)Page 28
Practical No:
Date:
localhost:49176/Qudratic equatix
C
localhost:49176/Qudratic_equation.aspx
Roots are Imaginary First Roots is-1 Second Roots is1.73205080756888
QuadraticEquation
Smt.Janakibai Rama Salvi College Kalwa(W)Page 29
(iv) Temperature Conversion.
Practical No:
Date:
converttemp c;
protected void Page_Load(object sender, EventArgs e)
c = new converttemp();
protected void Button1_Click(object sender, EventArgs e)
char ch;
ch = Convert.ToChar(TextBox1.Text);
if (ch == 'c')
c.celsius = float.Parse(TextBox2.Text);
c.converttofaren();
Label1.Text = "Celsius to Farenheit\n" + c. faren;
else
c. faren = float.Parse(TextBox2.Text);
c.converttocel();
Label1.Text="Farenheit to Celsius\n"+c.celsius;
Smt.Janakibai Rama Salvi College Kalwa(WPage 31
Practical No:
Date:
localhost:49679/Temperature_Co X
+
→ C
o
localhost:49679/Temperature Conversion/temperature conversion.aspx
Apps
A page can have only
100
Farenheit to Celsius 37.77778
Button
Smt.Janakibai Rama Salvi College Kalwa(WPage 32
Practical No:
Date:
2 Woriking With Object Oriented C# and ASP.NET.
(b) Create simple application to demonstrate use of following concepts.
(i) Function Overloading.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class overloading
public int sum(int a, int b)
int x;
return x = a + b;
public int sum(int a, int b, int c)
int y;
return y = a + b + c;
public float sum(float a, float b)
float u;
return u = a + b;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 33
Practical No:
Date:
public float sum(float a, float b, float c)
{
float v;
return v = a + b + c;
public partial class functionoverloading : System.Web.UI.Page
overloading o;
protected void Page_Load(object sender, EventArgs e)
o = new overloading();
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = Convert.ToString(o.sum(10, 20)); Label2.Text = Convert.ToString(0.sum(10, 20, 30));
Labe13. Text = Convert.ToString(o. sum(12.0f, 23.1f, 32.5f));
Smt.Janakibai Rama Salvi College Kalwa(WPage 34
Practical No:
Date:
localhost:50547/Function_Overlo X
+
O localhost:50547/Function Overloading/functionoverloading.aspx A page can have only
Apps
30
67.6
Button
Smt.Janakibai Rama Salvi College Kalwa(WPage 35
Practical No:
Date:
(ii) Inheritance (All Types)
Single Inheritance
using System; using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class basec
public int d;
public string basemethod()
string p = "This is baseclass method";
S
return p;
public class Derived : basec
{
public string derivedmethod()
string s = "This is derivedclassmethod";
return s;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 36
Practical No:
Date:
public partial class singleInheritance : System.Web.UI. Page
protected void Button1_Click(object sender, EventArgs e)
basec b=new basec();
Response.Write("Calling from base class object:" +b.basemethod());
Derived d = new Derived();
Response.Write("<br>Calling from derived class object:<br>" + d.basemethod());
Response.Write("<br>" + d. derivedmethod());
Smt.Janakibai Rama Salvi College Kalwa(W)Page 37
Practical No:
Date:
localhost:50584/ Single_Inheritan
X
+
→ C
o
O localhost: 505 84/Single_Inheritance/singlelnheritance.aspx
3: Apps
A page can have only
Calling from base class object:This is baseclass method Calling from derived class object: This is baseclass method This is derivedclassmethod
Button
Multi Level Inheritance
using System;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 38
Practical No:
Date:
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class A
public string show()
return ("First base Class");
class B :A
public string display ( )
return ("Second base Class");
class C : B
public string show1()
return "Child Class";
Smt.Janakibai Rama Salvi College Kalwa(WPage 39
Practical No:
Date:
public partial class MultiLevelInheritance : System.Web.UI. Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
C obj = new C();
Response.Write(obj.show() + "<br>");
Response.Write(obj.display() + "<br>");
Response.Write(obj.show1() + "<br>");
Smt.Janakibai Rama Salvi College Kalwa(W)Page 40
Practical No:
Date:
localhost: 50620/MultiLevellnherit X
+
f
→ C
localhost:50620/MultiLevellnheritance/MultiLevelinheritance.aspx
Apps
A page can have only
First base Class Second base Class Child Class
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 41
Practical No:
Date:
Multiple Inheritance
using System; using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class Shape
public int side;
public void setSide(int s)
{
side = S;
public interface Cost
int getCost(int area);
class square : Shape, Cost
public int getArea()
return (side * side);
Smt.Janakibai Rama Salvi College Kalwa(W)Page 42
Practical No:
Date:
public int getCost(int area)
return area * 10;
public partial class MULTIPLE_INHERITANCE : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
square sq = new square();
int area;
sq.setSide(15);
area = sq.getArea();
Label1.Text = "Area:" + area;
int c = sq.getCost(area);
Label2.Text = "Cost is Rs:" + c;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 43
Practical No:
Date:
localhost:50671/ multipleinherita x
+
+
→ C Apps
o O localhost:50671/multipleinheritance/MULTIPLE_INHERITANCE.aspx A page can have only
Area:225 Cost is Rs: 2250
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 44
Practical No:
Date:
Hierarchical Inheritance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class A
public string show()
return "Welcome";
class B : A
public string display()
return "to the World";
class C : A
public string show1()
{
Smt.Janakibai Rama Salvi College Kalwa(WPage 45
Practical No:
Date:
return "Of Programming";
public partial class HIERARCHICAL_INHERITANCE : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
C c1 = new C();
B b1 = new B();
string s = "";
s += c1.show();
s += b1.display();
s += c1. show1();
Label1.Text=s;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 46
Practical No:
Date:
|
localhost:50755/Hierarchicallnhe x
+
t
C
o localhost:50755/Hierarchicalinheritance/HIERARCHICAL_INHERITANCE.aspx
A page can have only
Apps
Welcometo the WorldOf Programming
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 47
Practical No:
Date:
(iii) Constructor overloading
using System; using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class MarkSheet
private float ml, m2, m3;
string name;
public MarkSheet()
{
m1 = 20; m2 = 40;
m3 = 40;
public MarkSheet(float ms)
m1 = ms;
public MarkSheet(float msn, float ms2)
m1 = ms1;
m2 = ms2;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 48
Practical No:
Date:
public MarkSheet(float msn, float ms2, float ms3)
{
m1 = ms1;
m2 = ms2;
m3 = ms3;
public float tot()
float t = m1 + m2 + m3;
return t;
public partial class Constructor_Overloading : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Marksheet a = new MarkSheet();
MarkSheet b = new MarkSheet(90);
Marksheet c = new MarkSheet(88, 60); MarkSheet d = new MarkSheet(70, 90, 55); Response.Write("In marksheet 1:");
ne
Response.Write(a.tot() + "<br>");
Smt.Janakibai Rama Salvi College Kalwa(WPage 49
Practical No:
Date:
Response.Write("In marksheet 2:");
Response.Write(b.tot() + "<br>");
Response.Write("In markseet 3:"); Response.Write(c.tot() + "<br>"); Response.Write("In marksheet 4:"); Response.Write(d.tot() + "<br>");
Smt.Janakibai Rama Salvi College Kalwa(W)Page 50
Practical No:
Date:
localhost:50774/ConstructorOve
X
+
→ C
o
localhost:50774/ConstructorOverloading/Constructor Overloading, aspx
Apps
A page can have only
In marksheet 1:100 In marksheet 2:90 In markseet 3:148 In marksheet 4:215
Button
(iv) Interface
Smt.Janakibai Rama Salvi College Kalwa(WPage 51
Practical No:
Date:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public interface ITransactions
string retcode();
double amtfunc();
public class Transaction : ITransactions
private string tCode;
private double amount;
public Transaction()
{
tCode = "";
amount = 0.0;
public Transaction(string c, double a)
tCode = c;
amount = a;
public double amtfunc()
Smt.Janakibai Rama Salvi College Kalwa(W)Page 52
Practical No:
Date:
return amount;
public string retcode()
return tCode;
public partial class INTERFACE : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Transaction t1 = new Transaction("Cr", 780.00);
: ney
Transaction t2 = new Transaction("Db", 400.00);
Response.Write("<br>Code" + t1.retcode());
Response.Write("<br>Amount" + t1.amtfunc());
Response.Write("<br>Code" + t2.retcode());
Response.Write("<br>Amount:" + t2.amtfunc());
Smt.Janakibai Rama Salvi College Kalwa(W)Page 53
Practical No:
Date:
localhost:50806/interface/INTERF X
+
e
o
localhost:50806/interface/INTERFACE.aspx
Apps
A page can have only
CodeCr Amount780 CodeDb Amount:400
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 54
Practical No:
Date:
2(c). Create simple applicaion to demonstrate use of following concepts
(i) Using Delegates and events
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Delegates_Events : System.Web.UI.Page
public delegate void SimpleDelegate();
public void callingFunction()
Response.Write("First Function Called....<br>");
}
public void secfunction()
Response.Write("Second Function Called...<br>");
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Smt.Janakibai Rama Salvi College Kalwa(WPage 55
Practical No:
Date:
SimpleDelegate sd = new SimpleDelegate(callingFunction);
sd();
sd += new SimpleDelegate(secfunction);
sd();
Smt.Janakibai Rama Salvi College Kalwa(W)Page 56
Practical No:
Date:
localhost:50843/Delegates_Event
+
C
o
localhost:50843/Delegates_Events/Delegates-Events.aspx
Apps
A page can have only
First Function Called.... First Function Called.... Second Function Called...
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 57
Practical No:
Date:
(ii) Exception Handling
using System; using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class NegativeException : Exception
public NegativeException(string msg)
: base(msg)
public partial class Exception_Handling : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
int num;
try
num = int.Parse(TextBox1.Text);
Smt.Janakibai Rama Salvi College Kalwa(W)Page 58
Practical No:
Date:
if (num < 0)
throw new NegativeException("Negative Number");
else
Console.WriteLine("Positive Number");
catch(NegativeException en)
Response.Write(en.Message);
Smt.Janakibai Rama Salvi College Kalwa(WPage 59
Practical No:
Date:
localhost:50860/ExceptionHandli x
+
+
→ C
o
localhost:50860/Exception Handling/Exception_Handling.aspx
Apps
A page can have only
Negative Number
-20
Button
Smt.Janakibai Rama Salvi College Kalwa(W)Page 60
Practical No:
Date:
Smt.Janakibai Rama Salvi College Kalwa(W)Page 61
Practical 3(b).Demonstrate the use of Calendar control to perform following operations.
Calender propertiesset for this example:
Date:
Practical No: <TodayDayStyle BackColor="#FFCC66" ForeColor="White" /> <WeekendDayStyle Height="50px" /> </asp:Calendar>
Smt.Janakibai Rama Salvi College Kalwa(W)Page 64
calndrCtrl.aspx.cs
Practical No:
Date:
protected void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
if (e.Day.Date.Day == 5 && e.Day.Date. Month == 9)
e.Cell.BackColor = System.Drawing.Color.Yellow; Label lbl = new Label(); lbl.Text = "<br>Teachers Day!"; e.Cell.Controls.Add(lbl); Image g1 = new Image(); g1.ImageUrl = "td.jpg"; g1.Height = 20; g1.Width = 20; e.Cell.Controls.Add(81);
Smt.Janakibai Rama Salvi College Kalwa(W)Page 66
Practical No:
Date:
}
if (e.Day.Date.Day == 13 && e.Day.Date.Month == 9)
Calendar1.SelectedDate = new DateTime(2018, 9, 12); Calendar1.SelectedDates.SelectRange(Calenda r1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label(); lbl1.Text = "<br>Ganpati!"; e.Cell.Controls.Add(lbll);
protected void btnReset_Click(object sender, EventArgs e)
Label1.Text = ""; Label2.Text = "";
Label3.Text = ""; Label4.Text = ""; Label5.Text = ""; Calendar1.SelectedDates.Clear();
protected void Calendar1_Selection Changed(object sender, EventArgs e)
Smt.Janakibai Rama Salvi College Kalwa(W)Page 67
Practical No:
Date:
Label1.Text = "Your Selected Date:" + Calendar1.SelectedDate.Date.ToString();
Smt.Janakibai Rama Salvi College Kalwa(W)Page 68
OUTPUT
Practical 3(c).Demonstrate the use of Treeview control perform following operations.
a) Treeview control and datalist b) Treeview operations
stdetail.xml
Default2.aspx
Date:
Practical No:
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" /> </asp:TreeView> <br /> Fetch Datalist Using XML data : </div> <asp:DataList ID="DataList1" runat="server">
<ItemTemplate> <table class = "table" border="1">
<tr> <td>Roll Num:<%# Eval("sid") %><br />
Name : <%# Eval("sname") %><br /> Class : <%# Eval("sclass")%> </td> </tr> </table> </ItemTemplate> </asp:DataList>
Smt.Janakibai Rama Salvi College Kalwa(W)Page 72
Practical No:
Date:
Default2.aspx
X | body ....
Treeview control navigation
ASP.NET Practs
Calendar Control Constructor Overloading
Inheritance D Class Properties
Fetch. Datalist Using XML data :
Roll Num - Databound Name : Databound Class : Databound
Roll Num - Databond Name : Databound Class - Databound
Roll Num - Databound Name : Databound Class = Databound
Roll Num - Databound Name : Databound Class : Databound
Roll Num = Databound Name : Databound Class - Databound
Smt.Janakibai Rama Salvi College Kalwa(W)Page 73
Default2.aspx.cs
OUTPUT
Practical No:
Date:
O
localhost:8652/Defaultza X
o localhost:8652/Default.aspa
latest hollywood hin
Tenda 1
Ireeview control tavigation:
ASP.NET Practs :D Calendar Controll
Constructor Overloading Inheritance Class Properties
Fetch Datalist Using XML data
Roll Num = 1 Name Tushar Class - TYIT
Roll Num - 2 Name = Sonali Class = TYCS Roll Num = 3 Name : Yashash I Class TYIT
Roll Num = 4 Name : Vedshree
Smt.Janakibai Rama Salvi College Kalwa(W)Page 76
Practical 4(b).Create Web Form to demonstrate use of Adrotator Control.
Date:
Practical No: Add images to test out the adrotator functionality.
Solution Explorer
@
$c 2 >> Search Solution Explorer (Ctrl+;)
Solution 'P4baddrotator' (1 project)
P4baddrotator
adds.xml Default.aspx Dove.jpg Hamam.jpg Lux.jpg Pears.jpg
Santoor.jpg
► Web.config
Smt.Janakibai Rama Salvi College Kalwa(W)Page 78
XML File
Date:
Practical No:
to Russia</Alternate Text> <Impressions>20</Impressions> <Keyword>russia</Keyword>
</Ad>
</Advertisements>
Smt.Janakibai Rama Salvi College Kalwa(W)Page 80
Default.aspx
OUTPUT:
Practical 4(c).Create Web Form to demonstrate use User Controls.
MyUserControl.ascx
Date:
Practical No:
<asp:Button ID="txtSave" runat="server" Text="Save" onclick="txtSave_Click" /> </td>
</tr>
</table><br /> <asp:Label ID="Labell" runat="server" ForeColor="White" Text=""></asp:Label>
Smt.Janakibai Rama Salvi College Kalwa(WPage 85
MyUserControl.ascx.cs
.aspx
<%@Register Src="~/ MyUserControl.asc TagPrefix="uc" TagName="Student"%>
<uc:Student ID="studentcontrol" runat="server" / >
OUTPUT :
Practical 5(b).Create a web application to demonstrate use of Master Page with applyingStylesand Themes for page beautification.
MasterPage.master
Practical No:
Date:
z-index: 1;
</style> </head>
Smt.Janakibai Rama Salvi College Kalwa(W)Page 90
Practical No:
Date:
<body>
<!DOCTYPE html> <form id="form1" runat"server">
<html> <head>
<title>Master</title>
<link rel="stylesheet" type="text/css"
href="StyleSheet.css"> </head>
<body> <header id="header"> <h1>Demo Of Master Page</h1> </header>
<nav id="nav">
<ul>
<li><a href="home.aspx">Insight</a></li> <li><a href="#">Products</a></li> <li><a href="#">Downloads</a></li> <li><a href="#">Contact Us</a></li>
</ul>
</nav>
<aside id="side">
Smt.Janakibai Rama Salvi College Kalwa(W)Page 91
Date:
Practical No: <h1>Info</h1>
<a href="#"><p>Product Type 1</p></a> <a href="#"><p>Product Type 2</p></a>
<a href="#"><p>Product Type 3<a href="#"><asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> </a>
</p>
<asp:Button ID="Button2" runat="server" CssClass="auto-style1" style="z-index: 1" Text="Button" />
<asp:Button ID="Button1" runat="server" CssClass="auto-style2" Text="Button" />
</aside>
<div id="con">
Smt.Janakibai Rama Salvi College Kalwa(WPage 92
Practical No:
Date:
<asp:ContentPlaceHolder ID="ContentPlaceholder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<footer id="footer">
copyright @Sambare </footer> </body>
</html>
</form>
</body> </html>
Smt.Janakibai Rama Salvi College Kalwa(W)Page 93
MasterDisplay.aspx
StyleSheet.css
Practical No:
Date:
ul{
list-style-type: none;
li a {
color:crimson ; font-size: 30px; column-width: 5%;
display: inline; padding-left: 2px; column-width: 20px;
a{ text-decoration: none; margin-left:20px
Smt.Janakibai Rama Salvi College Kalwa(WPage 95
Date:
Practical No:
li a:hover{ background-color: aqua;
color:coral ; padding:1%;
#side{
text-align: center; float: right; width: 15%;
padding-bottom: 79%;
background-color: #F1FAEE;
#article{ background-color: burlywood; padding: 10px; padding-bottom: 75%;
#footer{
background-color: #C7EFCF; text-align:center; padding-bottom: 5%; font-size: 20px;
Smt.Janakibai Rama Salvi College Kalwa(W)Page 96
Practical No:
Date:
#con{
border:double; border-color:burlywood;
}
Smt.Janakibai Rama Salvi College Kalwa(W)Page 97
***Database Practicals************
Practical No:
Date:
Data Connections
Workshop.mdf
Tables
► ACC_TRANSACTION
ACCOUNT
BRANCH > BUSINESS
CUSTOMER TO CUST_ID
ADDRESS CITY CUST_TYPE_CD FED_ID POSTAL_CODE
STATE
DEPARTMENT > EMPLOYEE > INDIVIDUAL
OFFICER PRODUCT TO PRODUCT_CD
DATE_OFFERED DATE_RETIRED NAME
PRODUCT_TYPE_CD
► PRODUCT_TYPE >> Views
Smt.Janakibai Rama Salvi College Kalwa(W)Page 99
Practical No:
Date:
Smt.Janakibai Rama Salvi College Kalwa(WPage 100
Practical 6 (a): Create a web application to bind data in a multiline textbox by querying in another textbox.
Button,
TextMode Multiline
Web.confing
Practical No:
Date: 2015\WebSites\Workshop\App_Data\Database.mdf';Integra ted Security=True" />
</connectionStrings>
</configuration>
Smt.Janakibai Rama Salvi College Kalwa(wPage 103
Note
Date:
Practical No:
SqlConnection con = new SqlConnection(connStr); con.Open();
SqlCommand cmd = new SqlCommand (TextBox1.Text, con); SqlDataReader reader = cmd.ExecuteReader(); ListBox1.Items.Clear(); while (reader.Read())
//To add new blank line in the text area
for (int i = 0; i < reader.FieldCount - 1; i++)
ListBox1.Items.Add(reader[i].ToString());
reader.Close(); con.Close();
Smt.Janakibai Rama Salvi College Kalwa(wPage 105
Output:
Practical 6 (b): Create a web application to display recordsby usingdatabase.
Output:
Practical 6 (c): Demonstrate the use of Datalist link control.
Choose Data Source <New Data Source>.
Date:
Practical No:
6. Keep the Authentication as Windows Authentication.
Authentication as W
Smt.Janakibai Rama Salvi College Kalwa(wPage 110
Practical No:
Date:
7. After that select Attach a Database file radio button. Here we
have to select the database that we have created in our application. (Usually it will be in Documents folder under Visual Studio 2015/ Websites).
8. After selection of Database file. We can also Test the
connection.
9. Then Click on OK button.
Configure Data Source - SqlDataSourcel
AFE
Choose Your Data Connection Add Connection
WE
Enter information to connect to the selected data source or click "Change to choose a different data source and/or provider.
New Connection...
Data source: Microsoft SQL Server (SqlClient)
Change...
Server name:
DESKTOP-FRAE37C\SQLEXPRESS
Refresh
racle, or OLEDB.
Log on to the server Authentication: Windows Authentication
Select SQL Server Database File
« DatabasePracts
App Data
Search App Data
User name:
Organize
Password:
New folder
A
This PC
Date modified
Type
Save my password
Name
Business Database
3D Objects
15-07-2018 15:24 15-07-2018 15:21
SQL Serv SQL Servi
Connect to a database
O Select or enter a database name:
Desktop Documents Downloads
O Attach a database file
File name Business
Microsoft SQL Server Database!
Browse...
Open
Cancel
Logical name:
O Attach Microsoft Visual Studio
C:\US
Web Sites Databaser
Browse...
Logic
Test connection succeeded.
OK
Advanced...
Test Connection
OK
Cancel
Smt.Janakibai Rama Salvi College Kalwa(wPage 111
Practical No:
Date: 10. Once the Connection is made then click on Next button from
Data Source Wizard.
Configure Data Source - SqlData Source1
Choose Your Data Connection
Which data connection should your application use to connect to the database? Database.mdf1
New Connection...
-
Connection string Data Source=DESKTOP-FRAE37C\SQLEXPRESS;AttachDbFilename=|DataDirectory Database.mdf;Integrated Security=True
-- Previous
Next >
Next >
Finish
Cancel
Smt.Janakibai Rama Salvi College Kalwa(wPage 112
Practical No:
Date:
11. Then wizard ask for saving the connection string in
configuration file. If you already stored it web.config file then uncheck check box, if you haven't, then select the checkbook. Then click on next button.
12. The next screen gives option to configure the select
statement. Here we can choose the table as well as configure the select statement as we need to display the data on web page.
Configure Data Source - SqlDataSource1
Configure the Select Statement
How would you like to retrieve data from your database?
Specify a custom SQL statement or stored procedure O Specify columns from a table or view
Name:
ACC_TRANSACTION
Columns
Return only unique rows
WHERE...
ORDER BY...
TXN_ID M AMOUNT
FUNDS_AVAIL_DATE MTXN_DATE MTXN_TYPE_CD
ACCOUNT_ID MEXECUTION_BRANCH_ID
TELLER EMP ID
Advanced...
SELECT statement:
SELECT [TXN IDI, AMOUNT], [FUNDS AVAIL_DATE], [TXN_DATE], [TXN_TYPE_CD], [ACCOUNT_ID],
[EXECUTION_BRANCH_ID], [TELLER_EMP_ID] FROM [ACC_TRANSACTION] 13. In next screen we can test our query to check the output. Then Click on finish.
< Previous
Next >
Finish
< Previous
Next >
Finish
Cancel
Smt.Janakibai Rama Salvi College Kalwa(wPage 113
Practical No:
Date: After successful steps form the Datalist controls option wizard our web page design and output will look like following.
Smt.Janakibai Rama Salvi College Kalwa(wPage 114
Practical No:
Date:
E
C
O localhost:3772/DataList.aspx
TXN_ID: 1 AMOUNT: 100 FUNDS AVAIL DATE: 1/15/2000 12:00:00 AM TXN DATE: 1/15/2000 12:00:00 AM TXN TYPE CD: CDT ACCOUNT_ID: 1 EXECUTION_BRANCH_ID: TELLER_EMP_ID:
TXN_ID: 2 AMOUNT: 100 FUNDS_AVAIL_DATE: 1/15/2000 12:00:00 AM TXN DATE: 1/15/2000 12:00:00 AM TXN_TYPE_CD: CDT ACCOUNT_ID: 2 EXECUTION_BRANCH_ID: TELLER_EMP_ID:
TXN_ID: 3 AMOUNT: 100 FUNDS_AVAIL_DATE: 6/30/2004 12:00:00 AM TXN DATE: 6/30/2004 12:00:00 AM TXN_TYPE_CD: CDT ACCOUNT ID: 3 EXECUTION BRANCH ID:
TELLER EMP_ID:
Smt.Janakibai Rama Salvi College Kalwa(wPage 115
Practical 7 (a): Create a web application to display Databinding usingDropdownlist control.
Code of C# Code behind file
Practical No:
Date:
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct City from Customer", con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); DropDownList1.DataSource = reader; DropDownList1.DataTextField = "City"; DropDownList1.DataBind(); reader.close(); con.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = "The You Have Selected : " + DropDownList1.SelectedValue;
Smt.Janakibai Rama Salvi College Kalwa(WPage 118
Practical No:
Date:
Output:
+ + CO
+
→ C
localhost:3772/DBD
Salem
Lynnfield Lynnfield Newton Quincy Salem Waltham Wilmington Woburn
Button
The You Have Selected : Salem
Smt.Janakibai Rama Salvi College Kalwa(WPage 119
Practical 7 (b): Create a web application for to display the Postal Code no of Customer using database.
Code of C# Code behind file
Practical No:
Date:
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = ListBox1.SelectedValue;
protected void Page_Load(object sender, EventArgs
e)
if (IsPostBack == false)
string connStr = Configuration Manager.ConnectionStrings ["connStr"].con nectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct POSTAL_CODE from Customer",
con);
con.Open();
Smt.Janakibai Rama Salvi College Kalwa(wPage 121
Practical No:
Date:
SqlDataReader reader = cmd.ExecuteReader(); ListBox1.DataSource = reader;
ListBox1.DataTextField = "City";
ListBox1.DataValueField = "POSTAL_CODE"; ListBox1.DataBind();
reader.Close(); con.Close();
م
م
م
Smt.Janakibai Rama Salvi College Kalwa(wPage 122
Output:
Practical 7 (c): Create a web application for inserting and deletingrecord from a database.(Using Execute-Non Query).
Code of C# Code behind file
Date:
Practical No:
cmd.Parameters.AddWith Value("@ADDRESS", TextBox1.Text);
cmd.Parameters.AddWithValue("@CITY", TextBox2.Text); cmd.Parameters.AddWithValue("@NAME", TextBox3.Text); cmd.Parameters.AddWithValue("@STATE", TextBox4.Text); cmd.Parameters.AddWithValue("@ZIP_CODE", TextBox5.Text); con.Open(); cmd.ExecuteNonQuery(); Label1.Text = "Record Inserted Successfuly.";
con.Close(;
protected void Button2_Click(object sender, EventArgs e)
string connStr = Configuration Manager.ConnectionStrings["connStr").Conne ctionString; SqlConnection con = new SqlConnection(connStr);
string InsertQuery = "delete from branch where NAME=@NAME";
SqlCommand cmd = new SqlCommand(InsertQuery, con); cmd.Parameters.AddWith Value("@NAME", TextBox1.Text); con.Open(); cmd.ExecuteNonQuery();
Smt.Janakibai Rama Salvi College Kalwa(W)Page 126
Date:
Practical No:
Label1.Text = "Record Deleted Successfuly.";
II
con.Close();
Smt.Janakibai Rama Salvi College Kalwa(W)Page 127
Practical No:
Date:
Page 128

Comments