Awp New Compiled
Awp New Compiled
Aim: create an application that obtained 4 integer value from the user and display the product.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1A
{ class Program
int a=Convert.ToInt32(Console.ReadLine());
int b= Convert.ToInt32(Console.ReadLine());
int c= Convert.ToInt32(Console.ReadLine());
int d= Convert.ToInt32(Console.ReadLine());
int p = a * b * c * d;
Console.ReadKey(); }}}
PRACTICAL 1B
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
string str1;
Console.Write("Enter String");
str1 = Console.ReadLine();
Console.WriteLine("\""+words[i]+"\"");
Console.ReadKey();
PRACTICAL 1C
Aim= create an application that receve student ID, strudent name,cource name,date of birth info from set of
student . the appshould also display the info of all students once the data is entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
struct Student
int i;
for(i=0;i<2;i++)
s[i].studid=Console.ReadLine();
s[i].name=Console.ReadLine();
s[i].cname=Console.ReadLine();
s[i].day=Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Month(1-12):");
s[i].month= Convert.ToInt32(Console.ReadLine());
Console.Write("Enter year:");
s[i].month = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n\nStudent's List\n");
for(i=0;i<2;i++)
Console.WriteLine("\nStudent ID:"+s[i].studid);
Console.WriteLine("\nStudent Name:"+s[i].name);
Console.ReadKey();
Console.WriteLine("\n\n\n"); }}}}
practical 1D
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
num = int.Parse(Console.ReadLine());
counter = 3;
break;
Console.Write("\t" + num3);
num1 = num2;
num2 = num3;
counter++;
Console.ReadKey();
}}}}
D(2) prime number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
Console.Write("Enter number:");
num = int.Parse(Console.ReadLine());
counter = 3;
for(counter=2;counter<=num/2;counter++)
if ((num % counter) == 0)
break;
if(num==1)
else if(counter<(num/2))
else
Console.ReadKey(); }}}
D(3) vowels
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
char ch;
ch = (char)Console.Read();
switch (ch)
case a':
case A':
case e':
case E':
case i':
case I':
case o':
case O':
case u':
case U':
break;
default:
break;
Console.ReadKey();}}}
D(4) Reverse
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practicalno1B
class Program
num = int.Parse(Console.ReadLine());
actualnumber = num;
Console.ReadKey(); } } }
Practical 1:
Practical_1(D) Create an application to demonstrate following operations
i. Generate Fibonacci series. ii. Test for prime numbers.
iii. Test for vowels. iv. Use of foreach loop with arrays
v. Reverse a number and find sum of digits of a number.
( i ): using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a=0, b=1, c,n;
Console.WriteLine("Enter Range:");
n=int.Parse(Console.ReadLine());
if (n >0)
{
Console.Write(a + " " + b + " ");
for (int i = 1; i <= n; i++)
{
c = a + b;
Console.Write(c + " ");
a = b;
b = c;
}
}
else
{
Console.WriteLine("Enter Valid number");
}
Console.ReadLine();
}
}
}
Output:
namespace prac1C_prime
{
class Program
{
static void Main(string[] args)
{
int num, c = 0;
Console.WriteLine("Enter a number:");
num=int.Parse(Console.ReadLine());
for (int i = 1; i <= num; i++)
{
if (num % i == 0)
c++;
}
if (c == 2)
{
Console.WriteLine(num + " is prime");
}
else
{
Console.WriteLine(num + " is not prime");
}
Console.ReadLine();
}
}
}
Output:
1.
2.
namespace isvowel
{
class Program
{
static void Main(string[] args)
{
char[] v = { 'a', 'e', 'i', 'o', 'u'};
char ch;
Console.WriteLine("Enter a Character:");
ch =Convert.ToChar(Console.ReadLine().ToLower());
for(int i=0;i<5;i++)
{
if (ch == v[i])
{
Console.WriteLine(ch + " is Vowel");
break;
}
else if (i ==4)
{
Console.WriteLine(ch + " is not vowel");
}
}
Console.ReadLine();
}
}
}
output:
1.
2.
(iv)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace foreachdemon
{
class Program
{
static void Main(string[] args)
{
int[] ch = { 1, 2, 3, 4, 5 };
foreach (int c in ch)
{
Console.Write(c+" ");
}
Console.ReadLine();
}
}
}
Output:
namespace reverse
{
class Program
{
static void Main(string[] args)
{
int n,num,rem, rev=0;
Console.WriteLine("Enter A number:");
n =int.Parse( Console.ReadLine());
num=n;
while (n > 0)
{
rem = n % 10;
rev = rev * 10 + rem;
n = n / 10;
}
Console.WriteLine("Reverse of " + num + " is " + rev);
Console.WriteLine("Reverse of " + num + " is " + rev);
Console.ReadLine();
}
}
}
output:
Practical 2
Practial_2(a): Create simple application to perform following operations
i. Finding factorial Value ii. Money Conversion
iii. Quadratic Equation iv. Temperature Conversion .
namespace factorial
{
class Program
{
static void Main(string[] args)
{
int n, fact=1;
Console.WriteLine("Enter a number: ");
n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("Factorial of " + n + " is " + fact);
Console.ReadLine();
}
}
}
output:
(ii):using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace monrey
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter 1 for converting doller to rupees:");
Console.WriteLine("enter 2 for converting euro to rupees:");
Console.WriteLine("enter 3 for converting pounds to rupees:");
int num = Convert.ToInt32(Console.ReadLine());
switch (num)
{
case 1:
Console.WriteLine("enter Doller amounnt:");
int dol = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter doller value:");
int v1 = Convert.ToInt32(Console.ReadLine());
int r1 = dol * v1;
Console.WriteLine(dol +" equals to " + r1 + " rupees");
break;
case 2:
Console.WriteLine("enter euro amounnt:");
int eur = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter euro value:");
int v2 = Convert.ToInt32(Console.ReadLine());
int r2 = eur * v2;
Console.WriteLine(eur + " equals to " + r2 + " rupees");
break;
case 3:
Console.WriteLine("enter Pound amounnt:");
int poun = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter Pound value:");
int v3 = Convert.ToInt32(Console.ReadLine());
int r3 = poun * v3;
Console.WriteLine(poun + " equals to " + r3 + " rupees");
break;
default:
Console.WriteLine("enter Proper choice:");
break;
}
Console.ReadLine();
}
}
}
output
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter value for a");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter value for b");
int b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter value for c");
int c = Convert.ToInt32(Console.ReadLine());
int d = (b * b) - (4 * a * c);
if (d > 0)
{
double r1 = (-b + Math.Sqrt(d)) / (2 * a);
double r2 = (-b - Math.Sqrt(d)) / (2 * a);
Console.WriteLine("r1:" + r1 + " r2:" + r2);
}
else if (d == 0)
{
double r3 = -b / (2 * a);
Console.WriteLine("root:" + r3);
}
else
{
Console.WriteLine("roots are imaginary");
}
Console.ReadLine();
}
}
}
Output:
(iv):using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace tempconv
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter 1 for converting degree to farnheit:");
Console.WriteLine("enter 2 for converting farnheit to degree :");
int num = Convert.ToInt32(Console.ReadLine());
switch (num)
{
case 1:
Console.WriteLine("enter degree value:");
double d = Convert.ToInt32(Console.ReadLine());
double far = d * 9 / 5+ 32;
Console.WriteLine("value in degrees is:" + far);
break;
case 2:
Console.WriteLine("enter farnheit value:");
double f= Convert.ToInt32(Console.ReadLine());
double degree = (f - 32 )*5/ 9;
Console.WriteLine("value in farnheit is:" + degree);
break;
default:
Console.WriteLine("enter proper choice:");
break;
}
Console.ReadLine();
}
}
}
Output:
Practical_2(b):
Create simple application to demonstrate use of following concepts
i.Function Overloading- Write Function overloading and Print the code
ii. Inheritance (all types) - Write note on all inheritance and Print the code
iii.Constructor overloading- Write constructor overloading and Print the code
iv. Interfaces Write Interfaces and Print the code .
(i):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace functoverload
{
class Program
{
public int Area(int a, int b)
{
return a * b;
}
public int Area(int a)
{
return a * a;
}
public double Area(double a)
{
return 3.14 *a *a;
}
}
class Program1
{
static void Main(string[] args)
{
Program s = new Program();
int rect= s.Area(6, 7);
int square=s.Area(5);
double circ= s.Area(5.7);
Console.Write("Area of React=" + rect + "\n");
Console.Write("Area of SqUARE=" + square + "\n");
Console.Write("Area of React=" + circ + "\n");
Console.ReadLine();
}
}
}
Output:
namespace single
{
class Program
{
static void Main(string[] args)
{
Teacher d = new Teacher();
d.Teach();
Student s = new Student();
s.Learn();
s.Teach();
Console.ReadLine();
}
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
}
Output:
multilevel inheritance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace multilevel
{
class Mode
{
public void mode()
{
Console.WriteLine("There are Many Modes of Transport !!");
}
}
class vehicle : Mode
{
public void feature()
{
Console.WriteLine("They Mainly Help in Travelling !!");
}
}
Output:
namespace constove
{
class BankAccount
{
private int cust_id;
private string cust_name;
private int bal;
public BankAccount()
{
cust_id = 1000;
cust_name = "Not Yet Specified";
bal = 0;
}
public BankAccount(int cust_id, string cust_name, int bal)
{
this.cust_id = cust_id;
this.cust_name = cust_name;
this.bal = bal;
}
public BankAccount(BankAccount obj)
{
cust_id = obj.cust_id;
cust_name = obj.cust_name;
bal = obj.bal;
}
public void ShowData()
{
Console.WriteLine("cust id = {0}, customer name = {1}, Bank Balance = {2}", cust_id,
cust_name, bal);
}
}
class Program
{
public static void Main(string[] args)
{
BankAccount a = new BankAccount(); // Invokes Default Constructor
BankAccount b = new BankAccount(102, "SAMKAM", 5000);// Invokes Parameterized Constructor
BankAccount c = new BankAccount(b);// Invokes Copy Constructor
a.ShowData();
b.ShowData();
c.ShowData();
Console.ReadLine();
}
}
Output:
Practical_2©:
Create simple application to demonstrate use of following concepts
i. Using Delegates and events Write what are Delegates and events and Print the code
ii. Exception handling Write Exception Handling and Print the code .
(i):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace delegate1
{
class Program
{
public delegate void Print(int value);
printDel(100000);
printDel(200);
printDel = PrintMoney;
printDel(10000);
printDel(200);
Console.ReadLine();
}
output:
Practical 3A
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PracNo3A.Scripts
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Button_click(object sender, EventArgs e)
{
if (TextBox1.Text.Equals("abc") && (TextBox2.Text.Equals("abc")))
{
Label1.Text = "Login Sussessful";
}
else
{
Label1.Text = "Login NotFiniteNumberException successful";
} } } }
Practical 3B
Button1 code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5.Scripts
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
Practical 3C
Xml FILE
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1</sid>
<sname>Reshma</sname>
<sclass>TYBSC(IT)</sclass>
</student>
<student>
<sid>2</sid>
<sname>Niraj</sname>
<sclass>TYCS</sclass>
</student>
<student>
<sid>3</sid>
<sname>Abhay</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>4</sid>
<sname>nitin</sname>
<sclass>TYCS</sclass>
</student>
</studentdetail>
4B <Adverisements>
<Ad>
<ImageUrl>Koala.jpg</ImageUrl>
<NavigateUrl>http://www.1800flowers.com</NavigateUrl>
<AlternateText>
Order flower,roses,gift and more
</AlternateText>
<Imptessions>20</Imptessions>
<Keyword>flowers</Keyword>
</Ad>
<Ad>
<ImageUrl>Jellyfish.jpg</ImageUrl>
<NavigateUrl>http://www.babybouques.com.au</NavigateUrl>
<AlternateText>
Order gift
</AlternateText>
<Imptessions>20</Imptessions>
</Ad>
<Ad>
<ImageUrl>Penguins.jpg</ImageUrl>
<NavigateUrl>http://www.1700moscow.com.au</NavigateUrl>
<AlternateText>
Send flower to USA
</AlternateText>
<Imptessions>20</Imptessions>
</Ad>
<Ad>
<ImageUrl>Hydrangeas.jpg</ImageUrl>
<NavigateUrl>http://www.flower2.com.au</NavigateUrl>
<AlternateText>
Send gift to Mumbai
</AlternateText>
<Imptessions>20</Imptessions>
</Ad>
</Adverisements>
5A <studendeail>
<student>
<Alli>1</Alli>
<sname>Sahil</sname>
<sclass>TYIT</sclass>
</student>
<student>
<Alli>2</Alli>
<sname>Vibhuti</sname>
<sclass>TYCS</sclass>
</student>
<student>
<Alli>3</Alli>
<sname>Jay</sname>
<sclass>TYIT</sclass>
</student>
<student>
<Alli>4</Alli>
<sname>Rahul</sname>
<sclass>TYCS</sclass>
</student>
OUTPUT
3A
5A
4A
3B
3C
4B
Practical 5(b)
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"
Inherits="MasterPage" %>
<!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"> <asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head>
<body>Hello<br />
<form id="form1" runat="server"> <div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder> </div> </form> </body> </html>
Default.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" Theme="SkinFile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Label
ID="Label1" runat="server" Text="Advanced web programming"></asp:Label> <br /> <asp:Label
ID="Label2" runat="server" Text="TYBScIT"></asp:Label> <br />
<asp:Label ID="Label3" runat="server" Text="Sem V"></asp:Label> <br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
</asp:Content>
Stylesheet.css:
body { background-color:Red;
font-family:Times New Roman;
font-size:25; }
Default.aspx.cs:
using System; using System.Collections.Generic; using System.Linq;
using System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e) { }
protected void Button1_Click(object sender, EventArgs e) {
Label4.Text = "Patkar College"; } }
Skinfile:<asp:Label runat="server" ForeColor="green" Font-Names="Verdana"/> <asp:Button
runat="server" Borderstyle="solid" Borderwidth="5px" />
5B
Practical 6 (a):
1. Create a webpage with one Button, one Multiline TextBox and one list box with setting TextMode
Property of text box to Multiline as shown below.
2. Write the Database related code in code behind C# file as given below.
3 Add this string to configuration file (web.config) as given below. Web.confing
<configuration> <system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" /> </system.web>
<connectionStrings> <add name="connStr"
connectionString="DataSource=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\tushars\Documents\
Visual Studio
2015\WebSites\Workshop\App_Data\Database.mdf';Integrated Security=True" /> </connectionStrings>
</configuration>
4. Now use the following code C# in Default.aspx.cs (Note : First write following using statements at the top
of file
using System; using System.Collections.Generic;
using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using
System.Data; using System.Data.SqlClient; using System.Configuration;
public partial class DataBinding : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
} protected void Button1_Click(object sender, EventArgs e)
{ string connStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString; SqlConnection con = new
SqlConnection(connStr); con.Open();
SqlCommand cmd = new SqlCommand(TextBox1.Text, con);
SqlDataReader reader = cmd.ExecuteReader(); ListBox1.Items.Clear(); while (reader.Read()) {
for (int i = 0; i < reader.FieldCount - 1; i++) { ListBox1.Items.Add(reader[i].ToString()); } }
reader.Close(); con.Close(); } }
Output:
Practical 6 (b):
Add the following code on Button click event in C# Code behind file.
protected void Button1_Click(object sender, EventArgs e)
{ string connStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString; SqlConnection con = new
SqlConnection(connStr); SqlCommand cmd = new SqlCommand("Select City, State from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
Label1.Text += reader["City"].ToString() + " " + reader["State"].ToString() + "<br>"; } reader.Close();
con.Close(); }
Output:
Practical 6 (c):
1. Drag the Datalist control to our web page form toolbox->Data-> Datalist.
2. Then select Choose Data Source Option and select <New Data Source>.
10. Once the Connection is made then click on Next button from Data Source Wizard.
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.
13. In next screen we can test our query to check the output. Then Click on finish.
After successful steps form the Datalist controls option wizard our web page design and output will look like
following.
Practical 7 (a)
Output:
Practical 7 (b):
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!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"/> <body> <form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" DataKeyField="id" DataSourceID="SqlDataSource4">
<ItemTemplate>
id: <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' /> <br />
fname: <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' /> <br />
lname: <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' /> <br />
city: <asp:Label ID="cityLabel" runat="server" Text='<%# Eval("city") %>' /> <br /> country: <asp:Label
ID="countryLabel" runat="server" Text='<%# Eval("country") %>' /> <br /> phoneno:
<asp:Label ID="phonenoLabel" runat="server" Text='<%# Eval("phoneno") %>' /> <br /> <br />
</ItemTemplate> </asp:DataList>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$
ConnectionStrings:DatabaseConnectionString3 %>"
SelectCommand="SELECT * FROM [customer]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT * FROM [cust]"></asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource2" Height="50px"
Width="125px" AutoGenerateRows="False" DataKeyNames="id"> <Fields>
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
<asp:BoundField DataField="fname" HeaderText="fname" SortExpression="fname" />
<asp:BoundField DataField="lname" HeaderText="lname" SortExpression="lname" />
<asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
<asp:BoundField DataField="country" HeaderText="country"
SortExpression="country" />
<asp:BoundField DataField="phoneno" HeaderText="phoneno"
SortExpression="phoneno" /> </Fields> </asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString2 %>"
SelectCommand="SELECT * FROM [customer]"></asp:SqlDataSource> <asp:FormView ID="FormView1"
runat="server" DataSourceID="SqlDataSource6" DataKeyNames="id"> <EditItemTemplate>
id: <asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>' /><br />
fname: <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' /> <br />
lname: <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
<br />
city: <asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>' /> <br />
country: <asp:TextBox ID="countryTextBox" runat="server" Text='<%# Bind("country") %>' />
<br />
phoneno: <asp:TextBox ID="phonenoTextBox" runat="server" Text='<%# Bind("phoneno") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate> <InsertItemTemplate>
id: <asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' />
<br /> fname:
<asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' /> <br /> lname:
<asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' /> <br /> city:
<asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>' />
<br /> country: <asp:TextBox ID="countryTextBox" runat="server" Text='<%# Bind("country") %>' />
<br /> phoneno:
<asp:TextBox ID="phonenoTextBox" runat="server" Text='<%# Bind("phoneno") %>' /> <br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate> <ItemTemplate>
id: <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
<br /> fname:
<asp:Label ID="fnameLabel" runat="server" Text='<%# Bind("fname") %>' /> <br /> lname:
<asp:Label ID="lnameLabel" runat="server" Text='<%# Bind("lname") %>' />
<br /> city:
<asp:Label ID="cityLabel" runat="server" Text='<%# Bind("city") %>' /> <br />
country: <asp:Label ID="countryLabel" runat="server" Text='<%# Bind("country") %>' />
<br />
phoneno: <asp:Label ID="phonenoLabel" runat="server" Text='<%# Bind("phoneno") %>' /> <br />
</ItemTemplate> </asp:FormView>8A
Practical no 9 A
Design:
XMLFile2.xml
<?xml version="1.0" encoding="utf-8" ?> <student>
<name>xyz</name> <roll>1</roll> </student>
XMLFile.xml Keep this file is empty for writing purpose.
Source Code:
using System; using System.Collections.Generic; using System.Linq;
using System.Web; using System.Web.UI;
using System.Web.UI.WebControls; using System.Xml;
public partial class _Default : System.Web.UI.Page {
protected void Button1_Click(object sender, EventArgs e) {
XmlReader red = XmlReader.Create(@"C:\Users\lenovo\Documents\Visual Studio
2010\WebSites\WebSite6\XMLFile2.xml");
while (red.Read()) { if (red.NodeType.Equals(XmlNodeType.Element))
{ string s = Label1.Text + " "; Label1.Text = s+ red.Name; } }
red.Close(); } protected void Button2_Click(object sender, EventArgs e)
{ XmlWriterSettings set = new XmlWriterSettings(); set.Indent = true;
XmlWriter wr = XmlWriter.Create(@"C:\Users\lenovo\Documents\Visual Studio
2010\WebSites\WebSite6\XMLFile.xml", set);
wr.WriteStartDocument(); wr.WriteComment("example of write to xml document");
wr.WriteStartElement("student"); wr.WriteEndElement(); } }
Output :
Prractical 9 B
Step 1: Choose Website -> ASP.NET Configuration to open the Web Application Administration Tool.
Step 2: Click on the Security tab.
Step 3: Select 'From the Internet' radio button option after clicking on ‘Select authentication type’ for form base
authentication and click on Done button.
Step 4: Go to the security tab again and click on ‘Enable role’ option for enabling roles for user.
Step9: Place a LoginStatus control on the Welcome.aspx from the login section of the toolbox. It has two
templates: LoggedIn and LoggedOut.
Step10: Place a LoginView control from the toolbox below the LoginStatus control.
Step11: The users for the application are created by the developer. You might want to allow a visitor to create a
user account. For this, add a link beneath the LoginView control, which should link to the CreateAccount.aspx
page.
Step12 : Place a CreateUserWizard control on the create account page. Set the ContinueDestinationPageUrl
property of this control to Welcome.aspx.
Step13 : Place a Login control on the Login page. The LoginStatus control automatically links to the Login.aspx.
To change this default, make the following changes in the web.config file.
For example, if you want to name your log in page as signup.aspx, add the following lines to the <authentication>
section of the web.config:
<configuration> <system.web> <authentication mode="Forms">
<forms loginUrl ="signup.aspx" defaultUrl = “Welcome.aspx” />
</authentication> </system.web> </configuration>
Step14 : Sometime user forget password. The PasswordRecovery control helps the user gain access to the
account. Select the Login control. Open its smart tag and click 'Convert to Template'. Customize the UI of the
control to place a hyperlink control under the login button, which should link to the PassWordRecovery.aspx
Step 15 : Place a PasswordRecovery control on the password recovery page. This control needs an email server
to send the passwords to the users.
Step16 : Create a link to the ChangePassword.aspx page in the LoggedIn template of the LoginView control in
Welcome.aspx.
Step17 : Place a ChangePassword control on the change password page. This control also has two views.
Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
%>
<!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">
</head> <body> <form id="form1" runat="server"> <div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> <br /> <br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="margin-left: 14px" Text="SHOW TIME" /> <br /> <br />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>PLEASEWAIT FOR SOMETIME </ProgressTemplate>
</asp:UpdateProgress> </div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel> </form> </body> </html>
Coding:
using System; using System.Collections.Generic; using System.Linq;
using System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
System.Threading.Thread.Sleep(2000); }
protected void Button1_Click(object sender, EventArgs e) {
TextBox1.Text = DateTime.Now.ToLongTimeString(); } }
OUTPUT :
Practiccal nono 9 B
Program 1: Program to create and use DLL.
using System; using System.Collections.Generic;
using System.Linq; using System.Text;
namespace ClassLibrary2 { public class Class1 {
public int add(int a, int b) { int c=a+b; return c; } } }
CODE :
using System; using System.Collections.Generic; using System.Linq;
using System.Text; using ClassLibrary;
namespace ConsoleApplication1 { class Program {
static void Main(string[] args) { ClassLibrary.Class1 c = new Class1();
int t=c.add(1, 2); Console.WriteLine("addition={0}",t); Console.ReadKey(); } } }
OUTPUT :
Practical No: 10
Perform logistic regression on the given data warehouse data.
The in-built data set "mtcars" describes different models of a car with their various engine specifications. In
"mtcars" data set, the transmission mode (automatic or manual) is described by the column am which is a binary
value (0 or 1). We can create a logistic regression model between the columns "am" and 3 other columns - hp, wt
and cyl.