C# Record
C# Record
C# Record
Using Window Forms Application, collect the user details like First Name, Middle Name,
Last Name, Gender, User Photo, Course name, Course Timing with Submit and Clear
button. Display the user detail in another form
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
Form2.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public Image Imageform
{
get;
set;
}
}
}
2. Create a Window Forms Application containing different genre of movies and one
button to display the favourite genre selected by user.
Form3.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
3.Create a Window Forms Application to demonstrate any 3 mouse and keyboard event
each
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
4.Create a Window Forms Application to load an image into a picture box using file open
dialogue box
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
5. Create a WPF Application for auto complete text box with suitable windows icon.
loginscreen.xaml
<Window x:Class="wpfloginscreen.loginscreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Login" Height="300" Width="300" FontSize="14" Background="green"
Loaded="Window_Loaded">
<Border Background="black" CornerRadius="20" Margin="10">
<StackPanel Margin="20">
<Label Content="Login" Foreground="white" FontSize="25"
HorizontalAlignment="Center"></Label>
<Separator></Separator>
<Label Content="Username" Foreground="White"/>
<TextBox Name="txtUsername" Background="Gray" Foreground="White"
FontSize="18"/>
<Label Content="Password" Foreground="White"/>
<TextBox Name="txtPassword" Background="Gray" Foreground="White"
FontSize="18" DataContext="{Binding}" />
<Button Name="btnSubmit" Background="Gray" Foreground="White"
FontSize="18" Content="Submit" Margin="60 10" Click="btnSubmit_Click"/>
</StackPanel>
</Border>
</Window>
loginscreen.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data.SqlClient;
namespace wpfloginscreen
{
/// <summary>
/// Interaction logic for loginscreen.xaml
/// </summary>
public partial class loginscreen : Window
{
public loginscreen()
{
InitializeComponent();
}
}
}
}
MainWindow.xaml
<Window x:Class="wpfloginscreen.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Label Content="Dashboard"/>
</Grid>
</Window>
7 Develop a database application to store the details of an employee using ADO.NET
using windows forms.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=Server1;Initial
Catalog=tejasvi15;Integrated Security=True");
private void textBox3_TextChanged(object sender, EventArgs e)
{
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
con.Open();
SqlCommand comm=new SqlCommand("Insert into Studentinfo_tab
values('"+Int16.Parse(TextBox1.Text)
+"','"+TextBox2.Text+"','"+DropDownList1.SelectedValue+"','"+double.Parse(TextBox3.Text)
+"','"+TextBox4.Text+"')",con);
comm.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Succesfully
inserted');",true);
LoadRecord();
}
void LoadRecord()
{
SqlCommand comm1 = new SqlCommand("select * from Studentinfo_tab",con);
SqlDataAdapter d = new SqlDataAdapter(comm1);
DataTable dt = new DataTable();
d.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand comm = new SqlCommand("update Studentinfo_tab set Studentname='" +
TextBox2.Text + "',Adress='" + DropDownList1.SelectedValue + "',Age='" +
double.Parse(TextBox3.Text)+"',Contact='"+TextBox4.Text+"' where
Studentid='"+Int16.Parse(TextBox1.Text)+"'", con);
comm.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Succesfully
updated');", true);
LoadRecord();
}
protected void Button3_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand comm = new SqlCommand("delete Studentinfo_tab where Studentid='" +
Int16.Parse(TextBox1.Text) + "'", con);
comm.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Succesfully
deleted');", true);
LoadRecord();
}
protected void Button4_Click(object sender, EventArgs e)
{
SqlCommand comm1 = new SqlCommand("select * from Studentinfo_tab where
Studentid='" + Int16.Parse(TextBox1.Text) + "'", con);
SqlDataAdapter d = new SqlDataAdapter(comm1);
DataTable dt = new DataTable();
d.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button5_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand comm1 = new SqlCommand("select * from Studentinfo_tab where
Studentid='" + Int16.Parse(TextBox1.Text) + "'", con);
SqlDataReader r=comm1.ExecuteReader();
while (r.Read())
{
TextBox2.Text = r.GetValue(1).ToString();
DropDownList1.SelectedValue = r.GetValue(2).ToString();
TextBox3.Text = r.GetValue(3).ToString();
TextBox4.Text = r.GetValue(4).ToString();
}
}
}
Web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\
SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\
aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices"
applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices"
applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
9 Create a asp.net web application using standard controls.
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
height: 23px;
}
.style3
{
height: 23px;
width: 306px;
}
.style4
{
width: 306px;
}
.style5
{
width: 306px;
height: 25px;
}
.style6
{
height: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
&nb
sp; <asp:Button
ID="Button2" runat="server" Text="Selected" />
&nb
sp;
<asp:Label ID="Label7" runat="server"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label5" runat="server" Text="Select color of
flower"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select any</asp:ListItem>
<asp:ListItem>Red roses</asp:ListItem>
<asp:ListItem>Black roses</asp:ListItem>
<asp:ListItem>Yellow roses</asp:ListItem>
</asp:DropDownList>
&nb
sp;
<asp:Button ID="Button3" runat="server" > Text="selected" />
&nb
sp;
<asp:Label ID="Label8" runat="server"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/images/ROSE.jfif">click here</asp:HyperLink>
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/Default3.aspx">See howe to grow roses</asp:LinkButton>
</td>
<td>
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="Label9" runat="server"></asp:Label>
&nb
sp;
&nb
sp;
<br />
<asp:Label ID="Label10" runat="server"></asp:Label>
<br />
<asp:Label ID="Label11" runat="server"></asp:Label>
</td>
<td class="style6">
<asp:CheckBox ID="CheckBox1" runat="server" Text="Roses have
thorns" />
<asp:CheckBox ID="CheckBox2" runat="server" Text="Roses different
colors" />
<asp:CheckBox ID="CheckBox3" runat="server"
Text="Could be used for rose syrup" />
<asp:Button ID="Button4" runat="server" > Text="checked" />
</td>
<td class="style6">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label12" runat="server"></asp:Label>
</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" Text="rose is fragrant"
/>
<asp:RadioButton ID="RadioButton2" runat="server" Text="no smell for
roses"
/>
&nb
sp;
<asp:Button ID="Button5" runat="server" >Text="done" />
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" Text="submit" />
&nb
sp;
&nb
sp;
&nb
sp;
<asp:Label ID="Label16" runat="server"></asp:Label>
</form>
</body>
</html>
Default3.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
When growing roses, it’s important to choose a site receiving at least six hours
of sun each day. Rose bushes must also be located in well-drained, fertile soil.
Plant dormant roses in early spring (or fall). Potted plants can be planted any
time between spring and fall, but preferably spring.
</form>
</body>
</html>
10 Create a web form to collect user details like Name (Required field validator),
password (Range validate), confirm password (compare validator), email (regular
expression validator), country name and phone number (range validator) with suitable
validation controls. Display validation summary. If validation is successful display the
user details.
Login.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs"
Inherits="Login" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 68%;
}
.style2
{
width: 244px;
}
.style4
{
width: 288px;
}
.style5
{
width: 207px;
}
#Password1
{
width: 190px;
}
#Password2
{
width: 189px;
}
.style6
{
width: 244px;
height: 26px;
}
.style7
{
width: 207px;
height: 26px;
}
.style8
{
width: 288px;
height: 26px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
User Id:</td>
<td class="style5">
<asp:TextBox ID="txt_userid" runat="server"
Width="195px"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_userid" Display="Dynamic"
ErrorMessage="Field is mandatory" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
Password</td>
<td class="style5">
<asp:TextBox ID="txt_password" runat="server" Width="192px"
TextMode="Password" ></asp:TextBox>
</td>
<td class="style4">
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="txt_password" Display="Dynamic"
ErrorMessage="Invalid password" ForeColor="Red"
>SetFocusOnError="True"
ValidateEmptyText="True">Invalid password</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style6">
Confirm Password</td>
<td class="style7">
<asp:TextBox ID="confirmbox" runat="server" Width="190px"
TextMode="Password"></asp:TextBox>
</td>
<td class="style8">
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txt_password" ControlToValidate="confirmbox"
Display="Dynamic" ErrorMessage="Password mismatch"
ForeColor="Red"
SetFocusOnError="True">Password mismatch</asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style2">
Email Id</td>
<td class="style5">
<asp:TextBox ID="txt_emailid" runat="server"
Width="191px"></asp:TextBox>
</td>
<td class="style4">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="txt_emailid" Display="Dynamic"
ErrorMessage="Invalid Emailid" ForeColor="Red"
SetFocusOnError="True"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\
w+)*">Invalid Emailid</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style2">
DOB</td>
<td class="style5">
<asp:TextBox ID="dob" runat="server" > Width="191px"></asp:TextBox>
</td>
<td class="style4">
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="dob"
Display="Dynamic" ErrorMessage="Age between 18-45"
ForeColor="Red"
SetFocusOnError="True" Type="Date">Age between
18-45</asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style2">
Country</td>
<td class="style5">
<asp:DropDownList ID="Countryselect" runat="server" >
<asp:ListItem Value="Select">Select a country</asp:ListItem>
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
<asp:ListItem>Dubai</asp:ListItem>
<asp:ListItem>China</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="Countryselect" Display="Dynamic"
ErrorMessage="country required" ForeColor="Red" InitialValue="Select"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
Mobile no:</td>
<td class="style5">
<asp:TextBox ID="phno" runat="server" Width="189px"></asp:TextBox>
</td>
<td class="style4">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server"
ControlToValidate="phno" Display="Dynamic"
ErrorMessage="RegularExpressionValidator" ForeColor="Red"
SetFocusOnError="True" ValidationExpression="\d{10}">10 digit mobile
no</asp:RegularExpressionValidator>
</td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" Text="submit" />
</form>
</body>
</html>
11 Create a web application using master page or which displays course list on left pane
on selecting the course its content.
MasterPage.master
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
width: 900px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="style1">
<tr>
<td>
<asp:Image ID="Image1" runat="server" Height="229px"
ImageUrl="~/images/dog.jfif" Width="897px" />
</td>
</tr>
<tr>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image2" runat="server" Height="150px"
ImageUrl="~/images/dog2.jfif" Width="25%" />
</td>
</tr>
</table>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
home.aspx
nested.master
<%@ Master Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="nested.master.cs" Inherits="nested" %>
Default2.aspx
About.aspx