Professional Documents
Culture Documents
using System.Xml;
namespace XML_Email_Sending
{
public partial class EmployeeForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
private void CreateNode(string appNo, string name, string Desig,string exp,string edu,string contact,
XmlTextWriter writer)
{
writer.WriteStartElement("Employee");
writer.WriteStartElement("AppNo");
writer.WriteString(appNo);
writer.WriteEndElement();
writer.WriteStartElement("Name");
writer.WriteString(name);
writer.WriteEndElement();
writer.WriteStartElement("Education");
writer.WriteString(edu);
writer.WriteEndElement();
writer.WriteStartElement("Designation");
writer.WriteString(Desig);
writer.WriteEndElement();
writer.WriteStartElement("Experience");
writer.WriteString(exp);
writer.WriteEndElement();
writer.WriteStartElement("Contact");
writer.WriteString(contact);
writer.WriteEndElement();
writer.WriteEndElement();
}
}
}
namespace vii_AjaxTimerControl
{
public partial class Time : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
OLX post
if (!IsPostBack)
{
BindData();
FillDropDownCategory();
FillDropDownCity();
}
}
GOOGLE MAP
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-
2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?">
</script>
<script type="text/javascript">
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
} else {
alert("Geo Location is not supported on your current browser!");
}
function success(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
var city = position.coords.locality;
document.getElementById('<%=txtLat.ClientID %>').value = lat;
document.getElementById('<%=txtLong.ClientID %>').value = long;
}
</script>
<body >
<form id="form1" runat="server">
<div>
<center>
<asp:Label runat="server" Text="Employee Sign Up" Font-Size="XX-Large"></asp:Label>
<br />
<table style="width:30%">
<tr>
<td>
<asp:Label Text="First Name" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFirstName" Font-Size="Large" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label Text="Last Name" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtLastName" Font-Size="Large" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label Text="Father Name" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFatherName" Font-Size="Large" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label Text="Gender" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:RadioButton ID="rdbtnMale" GroupName="Gender" Text="Male" TextAlign="Right" Font-
Size="Large" Checked="true" runat="server" />
<asp:RadioButton ID="rdbtnFemale" GroupName="Gender" Text="Female" TextAlign="Right" Font-
Size="Large" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" Text="Designation" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlDesignation" Font-Size="Large" runat="server" Width="100%">
<asp:ListItem>GM</asp:ListItem>
<asp:ListItem>Manager</asp:ListItem>
<asp:ListItem>Staff Member</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" Text="Shift" Font-Size="Large" runat="server"></asp:Label>
</td>
<td>
<asp:RadioButton ID="rdbtnMorning" GroupName="Shift" Text="Male" TextAlign="Right" Font-
Size="Large" Checked="true" runat="server" />
<asp:RadioButton ID="rdbtnEvening" GroupName="Shift" Text="Female" TextAlign="Right" Font-
Size="Large" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblStatus" runat="server" Text="Status" Visible="False"></asp:Label>
</td>
<td>
<asp:HiddenField ID="txtLat" runat="server" />
<asp:HiddenField ID="txtLong" runat="server" />
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" Width="100%"
Height="50px" Font-Size="Medium" />
</td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
GRID OPERTAION
namespace Grid_View_Operations
{
public partial class Student : System.Web.UI.Page
{
DataAccessLayer dal = new DataAccessLayer();
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
dal.OpenCon();
String gender = "";
if (rdoFemale.Checked == true)
gender = "Female";
else
gender = "Male";
if (FileUpload1.PostedFile == null)
{
lblStatus.Visible = true;
lblStatus.Text = "No Image Selected";
return;
}
string fileName = FileUpload1.PostedFile.FileName;
dal.InsertUpdateDelete("Insert into Student Values ('" + txtRegNo.Text + "','" + txtFirstName.Text + "','"
+ txtLastName.Text + "','" + gender + "','" + txtDescipline.Text + "','" + txtSection.Text + "','" + txtFatherName.Text
+ "','"+fileName+"')");
lblStatus.Visible = true;
FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~\Images\") + fileName);
lblStatus.Text = "Saved Successfully!";
}
catch (Exception ex)
{
lblStatus.Visible = true;
lblStatus.Text = ex.Message;
}
finally
{
dal.CloseCon();
}
}
DataAccessLayer
namespace Grid_View_Operations
{
public class DataAccessLayer
{
static string constr = @"Data Source=Fahad-PC;Initial Catalog=CMS;Integrated
Security=True;";
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd;
SqlDataAdapter sda;
DataTable dt;
public void OpenCon()
{
if (con.State == ConnectionState.Closed)
con.Open();
}
public void CloseCon()
{
if (con.State == ConnectionState.Open)
con.Close();
}
public void InsertUpdateDelete(string query)
{
cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
}
public DataTable GetData(string query)
{
sda = new SqlDataAdapter(query, con);
dt = new DataTable();
sda.Fill(dt);
return dt;
}
}
}
<asp:GridView ID="GridViewShowStudents" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None"
OnPageIndexChanging="GridViewShowStudents_PageIndexChanging"
OnRowCancelingEdit="GridViewShowStudents_RowCancelingEdit"
OnRowDeleting="GridViewShowStudents_RowDeleting" OnRowEditing="GridViewShowStudents_RowEditing"
OnRowUpdating="GridViewShowStudents_RowUpdating"
OnSelectedIndexChanged="GridViewShowStudents_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="AridNo" HeaderText="Arid No" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Descipline" HeaderText="Descipline" />
<asp:BoundField DataField="FatherName" HeaderText="Father Name" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:ImageField DataImageUrlField="ImageName" HeaderText="Image">
<ControlStyle Height="100px" Width="100px" />
</asp:ImageField>
<asp:CommandField ShowSelectButton="True" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
namespace Grid_View_Operations
{
public partial class StudentGridView : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=Fahad-PC;Initial Catalog=CMS;Integrated Security=True;");
SqlCommand cmd;
SqlDataAdapter sda;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
QUERY STRING
<body>
<form id="form1" runat="server">
<div>
<center>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="NAME"></asp:Label>
</td><td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td><td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="SEARCH" />
</td>
</tr>
<tr>
<td colspan="3">
<asp:GridView ID="GV" runat="server" AutoGenerateColumns="False"
OnSelectedIndexChanged="GV_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="regno" HeaderText="Reg" />
<asp:BoundField DataField="fname" HeaderText="First Name" />
<asp:BoundField DataField="lname" HeaderText="Last Name" />
<asp:CommandField SelectText="Display" ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</center>
</div>
</form</body>
namespace QueryString
{
public partial class StudentSearchingViaQS : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-JU9G6DU;Initial
Catalog=CRM;Integrated Security=True");
SqlDataAdapter sda;
SqlDataReader sdr;
SqlCommand cmd;
DataTable dt;
string Query = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sda.Fill(dt);
GV.DataSource = dt;
GV.DataBind();
con.Close();
}
sda.Fill(dt);
GV.DataSource=dt;
GV.DataBind();
con.Close();
}
namespace QueryString
{
public partial class Details : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-JU9G6DU;Initial
Catalog=CRM;Integrated Security=True");
SqlDataAdapter sda;
SqlCommand cmd;
DataTable dt;
SqlDataReader sdr;
}
private void FillDropDownDescipline()
{
con.Open();
sda = new SqlDataAdapter("Select * from prog", con);
dt = new DataTable();
sda.Fill(dt);
ddlDescipline.DataSource = dt;
ddlDescipline.DataTextField = "Descipline";
ddlDescipline.DataBind();
con.Close();
}
Session Management
namespace SessionManagement
{
public partial class Session : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["id"]!=null)
Response.Redirect("default.aspx");
}
}
}
}
namespace SessionManagement
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["id"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("session.aspx");
}
}
}