Anda di halaman 1dari 22

Q1 WAP to print hello using c#?

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

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("hello");
Console.ReadKey();
}
}
}
Q2 WAP to find factorial of a given number in c#?

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

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int f = 1;
int i;
for (i = 1; i <= 5; i++)
{
f = f * i;
}
Console.WriteLine(f);
Console.ReadKey();
}
}
}
Q3 WAP to reverse any given number in c#?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a No. to reverse");
int Number = int.Parse(Console.ReadLine());
int Reverse = 0;
while (Number > 0)
{
int remainder = Number % 10;
Reverse = (Reverse * 10) + remainder;
Number = Number / 10;
}
Console.WriteLine("Reverse No. is {0}", Reverse);
Console.ReadLine();
}
}
}
Q4 WAP in Asp .net to create wizard control?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2"
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<head runat="server">

<title></title>

</head>

<body>

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

<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1" CellPadding="2"

CellSpacing="2" Height="200px" Width="400px">

<NavigationButtonStyle BackColor="#CCFFFF" />

<SideBarStyle BackColor="#00FF99" />

<WizardSteps>

<asp:WizardStep runat="server" title="c++">

C++<br />

<br />

<p style="color: rgb(0, 0, 0); font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;
font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-
space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:
rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

C++ is a general purpose, case-sensitive, free-form programming language that

supports object-oriented, procedural and generic programming.</p>

<p style="color: rgb(0, 0, 0); font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;
font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-
space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:
rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

C++ is a middle-level language, as it encapsulates both high and low level


language features</p>

<br />

<br />

<br />

<br />

</asp:WizardStep>

<asp:WizardStep runat="server" title="c#">

C#<br />

<br />

<p style="color: rgb(0, 0, 0); font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;
font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-
space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:
rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

C# is pronounced as &quot;C-Sharp&quot;. It is an object-oriented programming


language

provided by Microsoft that runs on .Net Framework.</p>

<p style="color: rgb(0, 0, 0); font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;
font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-
space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:
rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

By the help of C# programming language, we can develop different types of

secured and robust applications:</p>

<ul class="points"

style="list-style: circle; font: 400 13px verdana, helvetica, arial, sans-serif; color: rgb(0, 0,
0); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-
space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:
rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

<li style="padding: 0.2em; line-height: 21px; color: rgb(0, 0, 0); margin-top: 4px;">

Window applications</li>

<li style="padding: 0.2em; line-height: 21px; color: rgb(0, 0, 0); margin-top: 4px;">

Web applications</li>

<li style="padding: 0.2em; line-height: 21px; color: rgb(0, 0, 0); margin-top: 4px;">

Distributed applications</li>
<li style="padding: 0.2em; line-height: 21px; color: rgb(0, 0, 0); margin-top: 4px;">

Web service applications</li>

<li style="padding: 0.2em; line-height: 21px; color: rgb(0, 0, 0); margin-top: 4px;">

Database applications etc.</li>

</ul>

<br />

<br />

<br />

<br />

</asp:WizardStep>

</WizardSteps>

</asp:Wizard>

&nbsp;</form>

</body>

</html>
Q5 WAP in asp .net to change background_color by click on radio button?

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


%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"


GroupName="i" oncheckedchanged="RadioButton1_CheckedChanged" Text="red" />
&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="i"
oncheckedchanged="RadioButton2_CheckedChanged" Text="green"
AutoPostBack="True" />
&nbsp;&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="i"
oncheckedchanged="RadioButton3_CheckedChanged" Text="blue"
AutoPostBack="True" />

</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default4 : System.Web.UI.Page


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

}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
r2.Attributes.Add("bgcolor", "red");
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
r2.Attributes.Add("bgcolor", "green");
}
protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
{
r2.Attributes.Add("bgcolor", "blue");
}
}
Q6 WAP in asp .net to create enquiry form?

<%@ 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">
<title></title>
<style type="text/css">
.style1
{
width: 800px;
border-style: solid;
border-width: 2px;
}
.style2
{
text-align: center;
font-size: xx-large;
color: #FFFFFF;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<table align="center" cellpadding="0" cellspacing="0" class="style1">


<tr>
<td class="style2" colspan="2" style="background-color: #33CC33">
<strong>Enquery Form</strong></td>
</tr>
<tr>
<td>
Roll No</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Name</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Address</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Gender</td>
<td style="text-align: justify">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
style="text-align: justify">
<asp:ListItem>Male</asp:ListItem>
</asp:RadioButtonList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RadioButtonList ID="RadioButtonList2" runat="server" AutoPostBack="True"
style="text-align: justify">
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
Course</td>
<td>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
<asp:ListItem>Java</asp:ListItem>
<asp:ListItem>.Net</asp:ListItem>
<asp:ListItem>Python</asp:ListItem>
<asp:ListItem>Angular</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
Duration</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
style="text-align: center">
<asp:ListItem>2 Month</asp:ListItem>
<asp:ListItem>4 Month</asp:ListItem>
<asp:ListItem>6 Month</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" style="background-color: #66FF66">
&nbsp;</td>
</tr>
<tr>
<td>
Roll No</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Name</td>
<td>
<asp:TextBox ID="TextBox5" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Address</td>
<td>
<asp:TextBox ID="TextBox6" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Courses</td>
<td>
<asp:TextBox ID="TextBox7" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Duration</td>
<td>
<asp:TextBox ID="TextBox8" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Fees</td>
<td>
<asp:TextBox ID="TextBox9" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center; background-color: #66FF66">
<asp:Button ID="Button1" runat="server" Text="Submit"
onclick="Button1_Click1" />
</td>
</tr>
</table>

</div>
</form>
</body>
</html>
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)
{
string RollNo=TextBox1.Text;
string Name = TextBox2.Text;
string Address = TextBox3.Text;
TextBox4.Text = RollNo;
TextBox5.Text = Name;
TextBox6.Text= Address;
string str = null;
int no = 0;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
no++;
str += CheckBoxList1.Items[i].Text + " ";
}
}
TextBox7.Text = str;
string Duration = DropDownList1.Text;
TextBox8.Text = Duration;
// =CheckBoxList1.Items.Counnt;
if (Duration == "2 Month")
{
int Fees = no * 5000;
Fees.ToString();
TextBox9.Text = Fees.ToString();
}
if (Duration == "4 Month")
{
int Fees = no * 10000;
Fees.ToString();
TextBox9.Text = Fees.ToString();
}
if (Duration == "6 Month")
{
int Fees = no * 15000;
Fees.ToString();
TextBox9.Text = Fees.ToString();
}
}
}
Q7 WAP in asp .net create validation form?
<%@ 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">
<title></title>
<style type="text/css">
.style1
{
width: 500px;
border-style: solid;
border-width: 2px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table align="center" class="style1">
<tr>
<td>
username</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="enter name"
SetFocusOnError="True" EnableTheming="True"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Email Id</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Invalid EmailId"
SetFocusOnError="True"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
password</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox3" ErrorMessage="is should be 10 digit"
MaximumValue="12" SetFocusOnError="True"></asp:RangeValidator>
</td>
</tr>
<tr>
<td>
c password</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox3" ControlToValidate="TextBox4"
ErrorMessage="password not match" SetFocusOnError="True"></asp:CompareValidator>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
</td>
</tr>
</table>
</form>
</body>
</html>
Q8 WAP in asp .net to create adrotator?
<%@ 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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" Height="150" Width="150"
AdvertisementFile="~/XMLFile.xml"/>
<asp:Button ID="Button1" runat="server" Text="change" onclick="Button1_Click" />
<br />

</div>
</form>
</body>
</html>
[Xml File]
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>ads/im1.jpg</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>google</AlternateText>
<Impression>90</Impression>
</Ad>
<Ad>
<ImageUrl>ads/img103.png</ImageUrl>
<NavigateUrl>http://www.twitter.com</NavigateUrl>
<AlternateText>twitter</AlternateText>
<Impression>90</Impression>
</Ad>
<Ad>
<ImageUrl>ads/im3.jpg</ImageUrl>
<NavigateUrl>http://www.gmail.com</NavigateUrl>
<AlternateText>gmail</AlternateText>
<Impression>90</Impression>
</Ad>
</Advertisements>
Q9 WAP in asp .net to create web user control?
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"
Inherits="WebUserControl" %>
<style type="text/css">
.style1
{
width: 500px;
}
</style>

<table align="center" class="style1">


<tr>
<td style="text-align: center">
<asp:Login ID="Login1" runat="server">
</asp:Login>
</td>
</tr>
</table>
[Drag control File]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
%>

<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<uc1:WebUserControl ID="WebUserControl1" runat="server" />

</form>
</body>
</html>
Q10 WAP in asp .net to create Multiview page?
<%@ 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">
<title></title>
</head>
<body>
<form id="form1" runat="server">

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"


onactiveviewchanged="MultiView1_ActiveViewChanged">
<asp:View ID="View1" runat="server">
<asp:Login ID="Login1" runat="server" Width="1100px">
</asp:Login>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:ChangePassword ID="ChangePassword1" runat="server" Width="1100px">
</asp:ChangePassword>
</asp:View>
</asp:MultiView>

</form>
</body>
</html>
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 MultiView1_ActiveViewChanged(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
}