0% found this document useful (0 votes)
71 views46 pages

Shaktiman

This document contains code for 10 programming practical examples: 1. A program that gets 4 numbers from the user and displays their product 2. A program that demonstrates string operations like substring, insert, remove, trim, and uppercase 3. A program that gets student data (ID, name, course, DOB) for 3 students and displays it 4. A program that calculates the factorial of a given number 5. A program that checks if a given character is a vowel 6. A program that reverses a given number and calculates the sum of its digits 7. A program that checks if a given number is prime 8. A program that calculates the sum of an array of numbers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views46 pages

Shaktiman

This document contains code for 10 programming practical examples: 1. A program that gets 4 numbers from the user and displays their product 2. A program that demonstrates string operations like substring, insert, remove, trim, and uppercase 3. A program that gets student data (ID, name, course, DOB) for 3 students and displays it 4. A program that calculates the factorial of a given number 5. A program that checks if a given character is a vowel 6. A program that reverses a given number and calculates the sum of its digits 7. A program that checks if a given number is prime 8. A program that calculates the sum of an array of numbers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 46

PRACTICAL NO.

:01

AIM : Create an application that obtains four int values from the user and displays
the products.

PROGRAM:

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

namespace PRODUCT
{
class Program
{
static void Main(string[] args)
{
int n1, n2, n3, n4, product;

Console.WriteLine("Enter the 1st number:");


n1 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the 2nd number:");


n2 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the 3rd number:");


n3 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the 4th number:");


n4 = Convert.ToInt32(Console.ReadLine());

product = n1*n2*n3*n4;

Console.WriteLine("The product of the 4 number is : " + product);


Console.ReadLine();

}
}
}

PRACTICAL NO.:02
AIM : Create an application to demonstrate string operations.

PROGRAM:

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

namespace PRODUCT
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Using substring function.......");
string name ="expert";
string sub = name.Substring(1, 3);
Console.WriteLine(sub);
Console.WriteLine("=====================\n");
name = "expert";
sub = name.Substring(2);
Console.WriteLine(sub);
Console.WriteLine("=================\n");
Console.WriteLine("using insert function.....");
name = "expert";
sub = name.Insert(2, "--");
Console.WriteLine(sub);
Console.WriteLine("=================\n");
Console.WriteLine("using removefunction......");
name = "ex--pert";
sub = name.Remove(2, 2);
Console.WriteLine(sub);
Console.WriteLine("==================\n");
Console.WriteLine("using trim function.......");
name = " i am c sharp expert ";
sub = name.Trim();
Console.WriteLine(sub);
Console.WriteLine("==================\n");
Console.WriteLine("using to upper function.........");
name = "expert";
sub = name.ToUpper();
Console.WriteLine(sub);
Console.ReadLine();

}
}
}

PRACTICAL NO.:03
AIM : Create an application that receives the (Student Id, Student Name, Course
Name,Date of Birth) information from a set of students. The application should
also display the information of all the students once the data entered.

PROGRAM:

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

namespace product
{
class Program
{
int stdid;
string name;
string course_name;
string DOB;
public void getdata()
{
Console.WriteLine("Enter the student ID:");
stdid = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the student name:");
name = Console.ReadLine();
Console.WriteLine("Enter the course name:");
course_name = Console.ReadLine();
Console.WriteLine("Enter the DOB:");
DOB = Console.ReadLine();
}
public void displayinfo()
{
Console.WriteLine("student id is:" + stdid);
Console.WriteLine("name is:" + name);
Console.WriteLine("course name is:" + course_name);
Console.WriteLine("DOB is:" + DOB);
}
static void Main(string[] args)
{
Program p1 = new Program();
Program p2 = new Program();
Program p3 = new Program();
Console.WriteLine("Enter the data for student 1:");
p1.getdata();
Console.WriteLine("Enter the data for student 2:");
p2.getdata();
Console.WriteLine("Enter the data for student 3:");
p3.getdata();
Console.WriteLine("***************");
Console.WriteLine("info of student 1:");
p1.displayinfo();
Console.WriteLine("info of student 2:");
p2.displayinfo();
Console.WriteLine("info of student 3:");
p3.displayinfo();
Console.ReadLine();

}
}
}
PRACTICAL NO.:04

AIM : Create an application to demonstrate Factorial .

PROGRAM:

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

namespace product
{
class Program
{

static void Main(string[] args)


{
int i, fact = 1, no = 5;
for (i = no; i >= 1; i--)
{
fact = fact * i;
}
Console.WriteLine("The factorial of {0} and {1}", no, fact);
Console.ReadLine();
}
}
}

PRACTICAL NO.:05
AIM : Create an application to demonstrate vowels .

PROGRAM:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace product

class Program

static void Main(string[] args)

char ch;

Console.WriteLine("Enter the character:");

ch = Convert.ToChar(Console.ReadLine());

switch (ch)

{
case 'a':

case 'A':

case 'e':

case 'E':

case 'i':

case 'I':

case 'o':

case 'O':

case 'u':

case 'U':

Console.WriteLine("{0} is vowel", ch);

break;

default:

Console.WriteLine(ch + "is not vowel");

break;

Console.ReadLine();

}
PRACTICAL NO.:06

AIM : Create an application to demonstrate reverse number .

PROGRAM:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace product

class Program

static void Main(string[] args)

int num;

Console.WriteLine("Enter the number to reverse:");

num = Convert.ToInt32(Console.ReadLine());

int sum = 0, rem, rev = 0;

while (num > 0)


{

rem = num % 10;

sum = sum + rem;

rev = (rev * 10) + rem;

num /= 10;

Console.WriteLine("reverse number is :" + rev);

Console.WriteLine("Sum of digit is:" + sum);

Console.ReadLine();

}
PRACTICAL NO.:07

AIM : Create an application to demonstrate to test whether the number is prime or


not .

PROGRAM:

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

namespace product
{
class Program
{

static void Main(string[] args)


{
int count=0,n;
Console.WriteLine("Enter the number:");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 2; i <= n / 2; i++)
{
if (n % i == 0)
{
count++;
}
}
if (count==0)
{
Console.WriteLine("The entered number is prime");
}
else
{
Console.WriteLine("The entered number is not prime");
}
Console.ReadLine();
}
}
}
PRACTICAL NO.:08

AIM : Create an application to demonstrate addition of array .

PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PRODUCT
{
class Program
{
public int addarray(params int[] list)
{
int sum = 0;
foreach(int i in list)
{
sum = sum + i;
}
return sum;
}
static void Main(string[] args)
{
int[] no = { 1, 2, 3, 4, 5, 6 };
Program p = new Program();
Console.WriteLine("the addition of array is {0}", p.addarray(no));
Console.ReadLine();
}
}
}
PRACTICAL NO.:09

AIM : Create simple application to demonstrate function overloading concept .

PROGRAM:
using System;
public class FunOverloading
{
public static int mul(int no1, int no2)
{
return no1 * no2;
}
public static int mul(int no1, int no2, int no3)
{
return no1 * no2 * no3;
}
public static float mul(float no1, float no2)
{
return no1 * no2;
}
}
public class Program
{
public static void Main()
{
Console.WriteLine("Multiplication of two integer numbers: " +
FunOverloading.mul(1, 22));
Console.WriteLine("Multiplication of three integer numbers: " +
FunOverloading.mul(1, 5, 10));
Console.WriteLine("Multiplication of two float numbers: " +
FunOverloading.mul(1.2F, 3.4F));
Console.ReadLine();
}
}
PRACTICAL NO.:10

AIM : Create simple application to demonstrate conductor overloading concept .

PROGRAM:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Add
{
class Add
{
public Add(int a)
{
Console.WriteLine("user enter single no. so addition is :" + a);
}
public Add(int a,int b)
{
Console.WriteLine("the addition of two number is :" + (a + b ));
}
public Add(int a,int b,int c)
{
Console.WriteLine("the addition of three number is :" + (a + b + c));
}
static void Main(string[] args)
{
Add p1 = new Add(5,6);
Add p2 = new Add(5);
Add p3 = new Add(5,6,7);
Add p4 = new Add(3,4);
Console.ReadLine();
}
}
}
PRACTICAL NO.:11(A)

AIM : Create simple application to demonstrate single inheritance .

PROGRAM:
using System;
public class EmpDemo
{
public float salary = 40000;
}
public class Bonus : EmpDemo
{
public float bonus = 10000;
}
class FinalClass
{
public static void Main(string[] args)
{
Bonus b1 = new Bonus();
Console.WriteLine("Salary : " + b1.salary);
Console.WriteLine("Bonus : " + b1.bonus);
Console.ReadLine();
}
}
PRACTICAL NO.:11(B)

AIM : Create simple application to demonstrate multilevel inheritance .

PROGRAM:
using System;
public class Animal
{
public void Eat()
{ Console.WriteLine("Eating..."); }
}
public class Dog : Animal
{
public void Bark()
{ Console.WriteLine("Barking..."); }
}
public class BabyDog : Dog
{
public void Weep()
{ Console.WriteLine("Weeping..."); }
}
public class MultilevelInheritance
{
public static void Main(string[] args)
{
BabyDog dog = new BabyDog();
dog.Eat();
dog.Bark();
dog.Weep();
Console.ReadLine();
}
}
PRACTICAL NO.:11(C)

AIM : Create simple application to demonstrate hierarchical inheritance .

PROGRAM:
using System;
namespace HierarchicalInheritaceDemo
{
class A
{
public void show()
{
Console.WriteLine("Welcome to the C#.");
}
}
class B : A
{
public void display()
{
Console.WriteLine("Hello TYIT.");
}
}
class C : A
{
public void show1()
{
Console.WriteLine("The subject name is Advanced Web Programming.");
}
}
class hierarchical
{
public static void Main()
{
B objl = new B();
C obj2 = new C();
objl.show();
objl.display();
obj2.show1();
Console.ReadLine();
}
}
}
PRACTICAL NO.:12

AIM : Create simple application to demonstrate interface .

PROGRAM:
using System;

namespace InterfaceDemo

class Program

static void Main(string[] args)

child ch = new child();

ch.message();

Console.ReadKey();

public interface I1

void message();

public interface I2

void message();
}

public class child : I1, I2

public void message()

Console.WriteLine("Multiple Inheritance Example.");

Console.ReadLine();

}
PRACTICAL NO.:13

AIM : Create simple application to demonstrate exception .

PROGRAM:
using System;

namespace exception_handling
{
class Bank : Exception
{
public Bank(string msg) : base(msg)
{
}
}
class Program
{
public int AccountNo;
public double Balance;
public Program(int AccNo, double bal)
{
try
{
AccountNo = AccNo;
Balance = bal;
if (bal < 500) throw new Bank("Oops !!! Amount is not sufficient");
}

catch (Bank e) { Console.WriteLine(e.Message); }

finally
{
Console.WriteLine("Account Number : {0} and Balance: {1}",
AccountNo, Balance);
}
}
static void Main(string[] args)
{
int a;
double b;
Console.WriteLine("Enter the Account Number and Balance : ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToDouble(Console.ReadLine());
Program obj = new Program(a, b);
Console.Read();
}
}
}

PRACTICAL NO.:14
AIM : Create simple application to demonstrate delegates .

PROGRAM:
using System;

public delegate void mydel(int x, int y);

namespace DelegateEX

class A

public static void add(int x, int y)

Console.WriteLine("The Sum is " + (x + y));

public static void sub(int x, int y)

Console.WriteLine("The Difference is " + (x - y));

class Program

static void Main(string[] args)


{

mydel m = new mydel(add);

m(5, 10);

mydel m1 = new mydel(sub);

m1(5, 10);

Console.ReadKey();

PRACTICAL NO.:15
AIM : Write a program to create a website to display product of four number .

PROGRAM:

default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> Multiplication of 4 Numbers </title>
<style type="text/css">
.auto-style1 {
width: 70%;
}
.auto-style2 {
width: 218px;
}
.auto-style3 {
width: 218px;
height: 30px;
}
.auto-style4 {
height: 30px;
}
</style>
</head>
<body id="Result">
<form id="form1" runat="server">
<div>
<table class="auto-style1" align="center">
<tr>
<td align="center" colspan="3" style="font-family: 'times New
Roman', Times, serif; font-size: x-large; background-color: #FFFF00; color:
#FF00FF;">Multiplication of 4 Numbers </td>
</tr>
<tr>
<td class="auto-style2">Enter First Number</td>
<td>:</td>
<td>
<asp:TextBox ID="txt1no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Second Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt2no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Third Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt3no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Fourth Number</td>
<td>:</td>
<td>
<asp:TextBox ID="Txt4no" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Button ID="Multiplication" runat="server"
OnClick="Multiplication_Click" Text="Multiplication" />
</td>
<td class="auto-style4"></td>
<td class="auto-style4"></td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Result" runat="server"></asp:Label>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</div>
</form>
</body>
</html>

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 Multiplication_Click(object sender, EventArgs e)


{
int a, b, c, d, r;
a = Convert.ToInt32(txt1no.Text);
b = Convert.ToInt32(Txt2no.Text);
c = Convert.ToInt32(Txt3no.Text);
d = Convert.ToInt32(Txt4no.Text);
r = a * b * c * d;
Result.Text = "Multiplication :" + r.ToString();
}
}
OUTPUT :

PRACTICAL NO.:16
AIM : Create Web Form to demonstrate use of Adrotator Control.

PROGRAM:

XML File.xml

<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

<Ad>

<ImageUrl>~/Images/a.png</ImageUrl>

<NavigateUrl>http://www.1800flowers.com</NavigateUrl>

<AlternateText>

Order roses

</AlternateText>

<Impressions>20</Impressions>

<Keyword>roses</Keyword>

</Ad>

<Ad>

<ImageUrl>~/Images/b.png</ImageUrl>

<NavigateUrl>http://www.babybouquets.com.au</NavigateUrl>

<AlternateText>scenery</AlternateText>

<Impressions>20</Impressions>

<Keyword>scenery</Keyword>

</Ad>
<Ad>

<ImageUrl>~/Images/c.png</ImageUrl>

<NavigateUrl>http://www.flowers2moscow.com</NavigateUrl>

<AlternateText>bappa</AlternateText>

<Impressions>20</Impressions>

<Keyword>bappa</Keyword>

</Ad>

</Advertisements>

OUTPUT :

PRACTICAL NO.:17
AIM : Create a website to demonstrate themes .

PROGRAM:

SkinFile.skin

<%--
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:Button runat="server" Forecolor="Cyan" Backcolor="Black"/>

Web.config

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages theme="Theme1"/>
</system.web>
</configuration>

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="welcome" runat="server" Text="Welcome" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;
<asp:Button ID="Button2" runat="server" Text="Home" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
</form>
</body>
</html>

OUTPUT :

PRACTICAL NO.:18
AIM : Create a web application to demonstrate use of Master page with applying
Styles for page beautifications .

PROGRAM:

MASTERPAGE.MASTER

<%@ Master Language="C#" AutoEventWireup="true"


CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 328px;
}
</style>
</head>
<body>

<form id="form1" runat="server">


<div>

<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Image ID="Image1" runat="server" Height="211px"
ImageUrl="~/gulmohar.png" Width="225px" />
</td>
<td style="border-style: dashed; font-family: 'Lucida Sans', 'Lucida
Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-
serif; font-style: oblique; color: #FF00FF; font-size: xx-large; background-color:
#00FFFF;">GULMOHAR FASHION
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HOUSE</td>
</tr>
<tr>
<td class="auto-style2">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/ABOUT US.aspx">ABOUT US</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="#">CONTACT US</asp:HyperLink>
</td>
<td><asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server"></asp:ContentPlaceHolder></td>
</tr>
<tr>
<td colspan="2" align="center" style="font-family: 'Arial Narrow';
font-size: large; font-style: italic; color: #00FFFF">&copy; GULMOHAR
FASHION HOUSE</td>
</tr>
</table>

</div>
</form>
</body>
</html>

DEFAULT.ASPX

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"


AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<p>
WELCOME TO GULMOHAR FASHION HOUSE
</p>
<p>
&nbsp;</p>
</asp:Content>

OUTPUT :

PRACTICAL NO.:19
AIM : Create a registration form to demonstrate various validation controls .

PROGRAM:

DEFAULT.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

<style type="text/css">

.auto-style1 {

width: 100%;

.auto-style2 {

width: 193px;

.auto-style3 {

width: 168px;

.auto-style4 {
width: 193px;

height: 26px;

.auto-style5 {

width: 168px;

height: 26px;

.auto-style6 {

height: 26px;

</style>

</head>

<body id="btnsubmit">

<form id="form1" runat="server">

<div>

<table class="auto-style1">

<tr>

<td class="auto-style2">&nbsp; NAME</td>

<td id="txtname" class="auto-style3">

<asp:TextBox ID="txtname" runat="server"></asp:TextBox>

</td>

<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtname" ErrorMessage="THIS IS
REQUIRED FIELD" ForeColor="Red"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class="auto-style2">&nbsp; PASSWORD</td>

<td class="auto-style3">

<asp:TextBox ID="txtpass" runat="server"


TextMode="Password"></asp:TextBox>

</td>

<td>&nbsp;</td>

</tr>

<tr>

<td class="auto-style2">&nbsp; CONFIRM PASSWORD</td>

<td class="auto-style3">

<asp:TextBox ID="txtconfirmpass" runat="server"


TextMode="Password"></asp:TextBox>

</td>

<td>

<asp:CompareValidator ID="CompareValidator1" runat="server"


ControlToCompare="txtpass" ControlToValidate="txtconfirmpass"
ErrorMessage="PASSWORD MISMATCH"
ForeColor="Red"></asp:CompareValidator>

</td>
</tr>

<tr>

<td class="auto-style4">&nbsp; EMAIL ID</td>

<td class="auto-style5">

<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>

</td>

<td class="auto-style6">&nbsp;<asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtemail"
ErrorMessage="THIS IS REQUIRED"
ForeColor="Red"></asp:RequiredFieldValidator>

&nbsp;&nbsp;

<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtemail"
ErrorMessage="NOT VALID EMAIL ID" ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td class="auto-style2">&nbsp; AGE</td>

<td class="auto-style3">

<asp:TextBox ID="txtage" runat="server"></asp:TextBox>

</td>

<td>
<asp:RangeValidator runat="server" ControlToValidate="txtage"
ErrorMessage="AGE SHOULD BE BETWEEN 18-56" ForeColor="Red"
MaximumValue="56" MinimumValue="18"></asp:RangeValidator>

</td>

</tr>

<tr>

<td class="auto-style2">&nbsp;</td>

<td class="auto-style3">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td class="auto-style2">&nbsp;

<asp:Button ID="Button1" runat="server" Text="SUBMIT" />

</td>

<td class="auto-style3">&nbsp;</td>

<td rowspan="2">

<asp:ValidationSummary ID="ValidationSummary1"
runat="server" ForeColor="Red" />

</td>

</tr>

<tr>

<td class="auto-style2">&nbsp;</td>

<td class="auto-style3">&nbsp;</td>

</tr>
</table>

</div>

</form>

</body>

</html>

OUTPUT :

PRACTICAL NO.:20
AIM : Create a web form to demonstrate use of user controls .

PROGRAM:

WebUserControl.ascx

<%@ Control Language="C#" AutoEventWireup="true"


CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<h3>This is User Contro1 </h3>
<table>
<tr>
<td>Name</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>City</td>
<td><asp:TextBox ID="txtcity" runat="server"></asp:TextBox></td>
</tr>

<tr>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="txtSave" runat="server" Text="Save"
onclick="txtSave_Click" />
</td>
</tr>
</table><br />
<asp:Label ID="Label1" runat="server" Text=" "></asp:Label>
WebUserControl.ascx.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 WebUserControl : System.Web.UI.UserControl


{
protected void Page_Load(object sender, EventArgs e)
{

protected void txtSave_Click(object sender, EventArgs e)


{
Label1.Text = "Your Name is " + txtName.Text + " and you are from "
+txtcity.Text;
}
}

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>
<%@ Register Src="~/WebUserControl.ascx" TagPrefix="uc"
TagName="Student"%>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc:Student ID="studentcontrol" runat="server" />
</div>
</form>
</body>
</html>

OUTPUT :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy