AWDT Practical - Solution
AWDT Practical - Solution
Program 2
Program 3
Program 4
if (RadioButton3.Checked == true)
{
TextBox2.Text = (int.Parse(TextBox1.Text) * int.Parse(TextBox1.Text)).ToString();
}
if (RadioButton4.Checked == true)
{
int i,f=1;
for ( i = 1; i <= int.Parse(TextBox1.Text); i++)
{
f = f * i;
}
TextBox2.Text = f.ToString();
}
}
Program 5
if (RadioButton2.Checked == true)
{
TextBox2.Text = TextBox1.Text.ToLower();
}
if (RadioButton3.Checked == true)
{
TextBox2.Text = TextBox1.Text.Substring(TextBox1.Text.Length-5);
}
if (RadioButton4.Checked == true)
{
TextBox2.Text = TextBox1.Text.Substring(0,5);
}
}
Program 6
Program 7
Program 8
Program 9
if (RadioButton1.Checked == true)
{
Panel1.BorderStyle = BorderStyle.None;
}
if (RadioButton2.Checked == true)
{
Panel1.BorderStyle = BorderStyle.Double;
}
if (RadioButton3.Checked == true)
{
Panel1.BorderStyle = BorderStyle.Solid;
}
if (CheckBox1.Checked == true)
{
Image1.ImageUrl = "~/Image/Sunset.jpg";
}
else
{
Image1.ImageUrl = "";
}
if (DropDownList1.SelectedValue == "Black")
{
Panel1.BackColor = System.Drawing.Color.Black;
}
if (DropDownList1.SelectedValue == "Red")
{
Panel1.BackColor = System.Drawing.Color.Red;
}
if (DropDownList1.SelectedValue == "Yellow")
{
Panel1.BackColor = System.Drawing.Color.Yellow;
}
if (DropDownList1.SelectedValue == "Blue")
{
Panel1.BackColor = System.Drawing.Color.Blue;
}
if (DropDownList1.SelectedValue == "Green")
{
Panel1.BackColor = System.Drawing.Color.Green;
}
}
Program 10
TextBox9.Text = (int.Parse(TextBox8.Text)/5).ToString();
To set up required field validation for TextBox1 (First Name) and TextBox2 (Last
Name) using RequiredFieldValidator controls in an ASP.NET Web Forms application,
follow these steps:
Select Control to Validate:
Set ControlToValidate to TextBox1 and TextBox2 for the respective validators.
Set Error Message:
Use the ErrorMessage property to specify what message should appear when validation fails.
Set Error Message Color:
Use the ForeColor property to change the color of the error message text to red.
Program 12
To set up range validation for an age input in an ASP.NET Web Forms application
using the RangeValidator control, follow these steps:
1 Add Controls:
Add TextBox1 for the password and TextBox2 for the re-typed password.
Add a CompareValidator control to compare the values of TextBox1 and TextBox2.
2 Configure CompareValidator:
ControlToCompare: Set to TextBox1 (original password).
ControlToValidate: Set to TextBox2 (re-typed password).
ErrorMessage: Set to "* Both Passwords Must Be Same".
ForeColor: Set to Red.
Program 14
Program 15
Program 16
Program 18
Program 19
WF_19_1.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace p19
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["firstvale"] != null)
{
Label1.Text = Session["firstvale"].ToString();
}
if (Session["ischk"] != null)
{
bool isChecked = (bool)Session["ischk"];
Label2.Text = isChecked ? "Yes" : "No";
}
}
}
}
}
Program 20
XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/Images/HP.jpg</ImageUrl>
<NavigateUrl>https://www.instagram.com/hardikpandya93/?hl=en</NavigateUrl>
<AlternateText>Kung Fu Pandya , Barodian</AlternateText>
<Impression>30</Impression>
<Keywords>HP king</Keywords>
</Ad>
<Ad>
<ImageUrl>~/Images/MSD.jpg</ImageUrl>
<NavigateUrl>https://www.instagram.com/mahi7781/?hl=en</NavigateUrl>
<AlternateText>Thala</AlternateText>
<Impression>30</Impression>
<Keywords>MSD</Keywords>
</Ad>
<Ad>
<ImageUrl>~/Images/VK.jpeg</ImageUrl>
<NavigateUrl>https://www.instagram.com/virat.kohli/?hl=en</NavigateUrl>
<AlternateText>King Kohli</AlternateText>
<Impression>20</Impression>
<Keywords>VK</Keywords>
</Ad>
</Advertisements>
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="p20.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center><h1>Ad rotator control</h1>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/XMLFile2.xml"
/>
</center>
</div>
</form>
</body>
</html>
Program 21
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="prg21.Site1" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:Image ID="Image1" runat="server" Height="200px" ImageUrl="~/Images/Virat-Kohli-18.jpeg" Width="1194px" />
</td>
</tr>
<tr>
<td>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<DynamicSelectedStyle HorizontalPadding="50px" ItemSpacing="70px" VerticalPadding="70px" />
<Items>
<asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem Text="About Us" Value="About Us"></asp:MenuItem>
<asp:MenuItem Text="Services" Value="Services"></asp:MenuItem>
<asp:MenuItem Text="Products" Value="Products"></asp:MenuItem>
<asp:MenuItem Text="Contact Us" Value="Contact Us"></asp:MenuItem>
</Items>
<StaticMenuItemStyle HorizontalPadding="40px" ItemSpacing="10px" />
</asp:Menu>
</td>
</tr>
</table>
<div>
namespace DataBaseProg
{
public partial class Login22 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ankit
Vaghela\source\repos\DataBaseProg\App_Data\Database1.mdf;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
namespace DataBaseProg
{
public partial class SignUp23 : System.Web.UI.Page
{
SqlConnection con =new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ankit
Vaghela\source\repos\DataBaseProg\App_Data\Database1.mdf;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
con.Close();
if (rowaff > 0)
{
Response.Write("<script language=javascript>confirm('success')</script>");
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
}
}
}
Program 24
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DataBaseProg
{
public partial class CEF24 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ankit
Vaghela\source\repos\DataBaseProg\App_Data\Database1.mdf;Integrated Security=True");
con.Close();
if (rowaff > 0)
{
Response.Write("<script language=javascript>confirm('success')</script>");
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
}
}
namespace DataBaseProg
{
public partial class EmpInfo25 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ankit
Vaghela\source\repos\DataBaseProg\App_Data\Database1.mdf;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
con.Close();
if (rowaffi > 0)
{
Response.Write("<script language=javascript>confirm('Inserted successfully')</script>");
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
string up = "update emp set empname='" + txtName.Text + "',dob='"+txtdob.Text+"' ,addr='"+txtAdd.Text+ "' ,
cno='"+txtCno.Text+"' ,city='"+txtCity.Text+"',country='"+txtCountry.Text+"' where empid='" + txtId.Text + "'";
SqlCommand com = new SqlCommand(up, con);
con.Open();
int rowaffu = Convert.ToInt32(com.ExecuteNonQuery());
con.Close();
if (rowaffu > 0)
{
Response.Write("<script language=javascript>confirm('Updated successfully')</script>");
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
}
}
con.Close();
if (rowaffd > 0)
{
Response.Write("<script language=javascript>confirm('Deleted Successfully')</script>");
}
else
{
Response.Write("<script language=javascript>confirm('Something Went Wrong')</script>");
}
}
Program 26
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Net.NetworkInformation;
using System.Web.UI.WebControls;
Program 27
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Program 28
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Program 29
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;