Main Css ...Name is Site.css
/* DEFAULTS
----------------------------------------------------------*/
body
{
background: orange;
font-size: .80em;
font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;
margin: 0px;
padding: 0px;
color: #696969;
}
a:link, a:visited
{
color: #034af3;
}
a:hover
{
color: #1d60ff;
text-decoration: none;
}
a:active
{
color: #034af3;
}
p
{
margin-bottom: 10px;
line-height: 1.6em;
}
/* HEADINGS
----------------------------------------------------------*/
h1, h2, h3, h4, h5, h6
{
font-size: 1.5em;
color: #666666;
font-variant: small-caps;
text-transform: none;
font-weight: 200;
margin-bottom: 0px;
}
h1
{
font-size: 1.6em;
padding-bottom: 0px;
margin-bottom: 0px;
}
h2
{
font-size: 1.5em;
font-weight: 600;
}
h3
{
font-size: 1.2em;
}
h4
{
font-size: 1.1em;
}
h5, h6
{
font-size: 1em;
}
/* this rule styles <h1> and <h2> tags that are the
first child of the left and right table columns */
.rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2
{
margin-top: 0px;
}
/* PRIMARY LAYOUT ELEMENTS
----------------------------------------------------------*/
.page
{
width: 90%;
background-color: #fff;
margin: 20px auto 0px auto;
border: 1px solid #496077;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
.header
{
position: relative;
margin: 0px;
padding: 0px;
background: #ffffff;
width: 100%;
}
.header h1
{
border-style: none;
border-color: inherit;
border-width: medium;
font-weight: 700;
margin: 0px;
padding: 0px 0px 0px 20px;
color: #3b5998;
line-height: 2em;
font-size: 2em;
width: 356px;
}
.main
{
padding: 0px 12px;
margin: 12px 8px 8px 8px;
min-height: 420px;
width: 90%;
}
.leftCol
{
padding: 6px 0px;
margin: 12px 8px 8px 8px;
width: 200px;
min-height: 200px;
}
.footer
{
color: #4e5766;
padding: 8px 0px 0px 0px;
margin: 0px auto;
text-align: center;
line-height: normal;
}
/* TAB MENU
----------------------------------------------------------*/
div.hideSkiplink
{
background-color: #3a4f63;
width: 100%;
}
div.menu
{
padding: 4px 0px 4px 8px;
}
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
div.menu ul li a, div.menu ul li a:visited
{
background-color: #465c71;
border: 1px #4e667d solid;
color: #dde4ec;
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
div.menu ul li a:hover
{
background-color: #bfcbd6;
color: #465c71;
text-decoration: none;
}
div.menu ul li a:active
{
background-color: #465c71;
color: #cfdbe6;
text-decoration: none;
}
/* FORM ELEMENTS
----------------------------------------------------------*/
fieldset
{
margin: 1em 0px;
padding: 1em;
border: 1px solid #ccc;
}
fieldset p
{
margin: 2px 12px 10px 10px;
}
fieldset.login label, fieldset.register label, fieldset.changePassword label
{
display: block;
}
fieldset label.inline
{
display: inline;
}
legend
{
font-size: 1.1em;
font-weight: 600;
padding: 2px 4px 8px 4px;
}
input.textEntry
{
width: 320px;
border: 1px solid #ccc;
}
input.passwordEntry
{
width: 320px;
border: 1px solid #ccc;
}
div.accountInfo
{
width: 42%;
}
/* MISC
----------------------------------------------------------*/
.clear
{
clear: both;
}
.title
{
display: block;
float: left;
text-align: left;
padding-top: 20px;
}
.loginDisplay
{
font-size: 1.1em;
display: block;
text-align: right;
padding: 10px;
color: #3b5998;
}
.loginDisplay a:link
{
color: #3b5998;
}
.loginDisplay a:visited
{
color: #3b5998;
}
.loginDisplay a:hover
{
color: #3b5998;
}
.failureNotification
{
font-size: 1.2em;
color: Red;
}
.bold
{
font-weight: bold;
}
.submitButton
{
text-align: right;
padding-right: 10px;
}
.texBox
{
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
.rounded_corners
{
border: 1px solid #A1DCF2;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
overflow: hidden;
border-collapse: collapse;
}
.rounded_corners td, .rounded_corners th
{
border: 1px solid #A1DCF2;
font-family: Arial;
font-size: 10pt;
text-align: center;
padding: 8px;
}
.rounded_corners table table td
{
border-style: none;
}
.myGridStyle
{
border-collapse: collapse;
}
.myGridStyle tr th
{
padding: 8px;
color: white;
border: 1px solid black;
}
.myGridStyle tr:nth-child(even)
{
background-color: #E1FFEF;
}
.myGridStyle tr:nth-child(odd)
{
background-color: #00C157;
}
.paging
{
}
.paging a
{
background-color: #00C157;
padding: 5px 7px;
text-decoration: none;
border: 1px solid #00C157;
}
.paging a:hover
{
background-color: #E1FFEF;
color: #00C157;
border: 1px solid #00C157;
}
.paging span
{
background-color: #E1FFEF;
padding: 5px 7px;
color: #00C157;
border: 1px solid #00C157;
}
tr.paging
{
background: none !important;
}
tr.paging tr
{
background: none !important;
}
tr.paging td
{
border: none;
}
----------------------------------------------------------*/
body
{
background: orange;
font-size: .80em;
font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;
margin: 0px;
padding: 0px;
color: #696969;
}
a:link, a:visited
{
color: #034af3;
}
a:hover
{
color: #1d60ff;
text-decoration: none;
}
a:active
{
color: #034af3;
}
p
{
margin-bottom: 10px;
line-height: 1.6em;
}
/* HEADINGS
----------------------------------------------------------*/
h1, h2, h3, h4, h5, h6
{
font-size: 1.5em;
color: #666666;
font-variant: small-caps;
text-transform: none;
font-weight: 200;
margin-bottom: 0px;
}
h1
{
font-size: 1.6em;
padding-bottom: 0px;
margin-bottom: 0px;
}
h2
{
font-size: 1.5em;
font-weight: 600;
}
h3
{
font-size: 1.2em;
}
h4
{
font-size: 1.1em;
}
h5, h6
{
font-size: 1em;
}
/* this rule styles <h1> and <h2> tags that are the
first child of the left and right table columns */
.rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2
{
margin-top: 0px;
}
/* PRIMARY LAYOUT ELEMENTS
----------------------------------------------------------*/
.page
{
width: 90%;
background-color: #fff;
margin: 20px auto 0px auto;
border: 1px solid #496077;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
.header
{
position: relative;
margin: 0px;
padding: 0px;
background: #ffffff;
width: 100%;
}
.header h1
{
border-style: none;
border-color: inherit;
border-width: medium;
font-weight: 700;
margin: 0px;
padding: 0px 0px 0px 20px;
color: #3b5998;
line-height: 2em;
font-size: 2em;
width: 356px;
}
.main
{
padding: 0px 12px;
margin: 12px 8px 8px 8px;
min-height: 420px;
width: 90%;
}
.leftCol
{
padding: 6px 0px;
margin: 12px 8px 8px 8px;
width: 200px;
min-height: 200px;
}
.footer
{
color: #4e5766;
padding: 8px 0px 0px 0px;
margin: 0px auto;
text-align: center;
line-height: normal;
}
/* TAB MENU
----------------------------------------------------------*/
div.hideSkiplink
{
background-color: #3a4f63;
width: 100%;
}
div.menu
{
padding: 4px 0px 4px 8px;
}
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
div.menu ul li a, div.menu ul li a:visited
{
background-color: #465c71;
border: 1px #4e667d solid;
color: #dde4ec;
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
div.menu ul li a:hover
{
background-color: #bfcbd6;
color: #465c71;
text-decoration: none;
}
div.menu ul li a:active
{
background-color: #465c71;
color: #cfdbe6;
text-decoration: none;
}
/* FORM ELEMENTS
----------------------------------------------------------*/
fieldset
{
margin: 1em 0px;
padding: 1em;
border: 1px solid #ccc;
}
fieldset p
{
margin: 2px 12px 10px 10px;
}
fieldset.login label, fieldset.register label, fieldset.changePassword label
{
display: block;
}
fieldset label.inline
{
display: inline;
}
legend
{
font-size: 1.1em;
font-weight: 600;
padding: 2px 4px 8px 4px;
}
input.textEntry
{
width: 320px;
border: 1px solid #ccc;
}
input.passwordEntry
{
width: 320px;
border: 1px solid #ccc;
}
div.accountInfo
{
width: 42%;
}
/* MISC
----------------------------------------------------------*/
.clear
{
clear: both;
}
.title
{
display: block;
float: left;
text-align: left;
padding-top: 20px;
}
.loginDisplay
{
font-size: 1.1em;
display: block;
text-align: right;
padding: 10px;
color: #3b5998;
}
.loginDisplay a:link
{
color: #3b5998;
}
.loginDisplay a:visited
{
color: #3b5998;
}
.loginDisplay a:hover
{
color: #3b5998;
}
.failureNotification
{
font-size: 1.2em;
color: Red;
}
.bold
{
font-weight: bold;
}
.submitButton
{
text-align: right;
padding-right: 10px;
}
.texBox
{
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
.rounded_corners
{
border: 1px solid #A1DCF2;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
overflow: hidden;
border-collapse: collapse;
}
.rounded_corners td, .rounded_corners th
{
border: 1px solid #A1DCF2;
font-family: Arial;
font-size: 10pt;
text-align: center;
padding: 8px;
}
.rounded_corners table table td
{
border-style: none;
}
.myGridStyle
{
border-collapse: collapse;
}
.myGridStyle tr th
{
padding: 8px;
color: white;
border: 1px solid black;
}
.myGridStyle tr:nth-child(even)
{
background-color: #E1FFEF;
}
.myGridStyle tr:nth-child(odd)
{
background-color: #00C157;
}
.paging
{
}
.paging a
{
background-color: #00C157;
padding: 5px 7px;
text-decoration: none;
border: 1px solid #00C157;
}
.paging a:hover
{
background-color: #E1FFEF;
color: #00C157;
border: 1px solid #00C157;
}
.paging span
{
background-color: #E1FFEF;
padding: 5px 7px;
color: #00C157;
border: 1px solid #00C157;
}
tr.paging
{
background: none !important;
}
tr.paging tr
{
background: none !important;
}
tr.paging td
{
border: none;
}
Master Page Source
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
<img alt="" src="Logs/logo.jpg" style="width: 192px; height: 73px" />
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Index.aspx"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Index.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/UserRegistration.aspx" Text="User Registration"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
User Registration Page
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="UserRegistration.aspx.cs" Inherits="UserRegistration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<h2>
Create a New Account
</h2>
<p>
Use the form below to create a new account.
</p>
<p>
Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length.
</p>
<span class="failureNotification">
<asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="RegisterUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="register">
<legend>Account Information</legend>
<p>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
<asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
<asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic"
ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server"
ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="CreateUserButton" runat="server" Text="Create User"
ValidationGroup="RegisterUserValidationGroup"/>
</p>
</div>
</asp:Content>
User Login
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="UserLogin.aspx.cs" Inherits="UserLogin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<h2>
Log In
</h2>
<p>
Please enter your username and password.
<asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
</p>
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="LoginUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="login">
<legend>Account Information</legend>
<p>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:CheckBox ID="RememberMe" runat="server"/>
<asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
</p>
</div>
</LayoutTemplate>
</asp:Login>
</asp:Content>
JavaScript Validation
<script type="text/javascript">
function userValid() {
var Name, pass, gender, conpass, EmailId, emailExp;
Name = document.getElementById('<%=txtUserId.ClientID %>').value;
gender = document.getElementById("<%=ddlType.ClientID %>").value;
pass = document.getElementById("<%=txtPass1.ClientID %>").value;
conpass = document.getElementById("<%=txtPass2.ClientID %>").value;
EmailId = document.getElementById("<%=txtmail.ClientID %>").value;
emailExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([com\co\.\in])+$/;
if (Name == '' && gender == 0 && pass == '' && conpass == '' && EmailId == '') {
alert("Please Enter All Fields");
return false;
}
if (Name == '') {
alert("Please Enter Login ID");
return false;
}
if (gender == 0) {
alert("Please Select gender");
return false;
}
if (pass == '') {
alert("Please Enter Password");
return false;
}
if (pass != '' && conpass == '') {
alert("Please Confirm Password");
return false;
}
if (pass != conpass) {
alert("Password not match");
return false;
}
if (EmailId == '') {
alert("Email Id Is Required");
return false;
}
if (EmailId != '') {
if (!EmailId.match(emailExp)) {
alert("Invalid Email Id");
return false;
}
}
return true;
}
function clearAllFeilds() {
document.getElementById('<%=txtUserId.ClientID %>').value = null;
document.getElementById("<%=ddlType.ClientID %>").value = null;
document.getElementById("<%=txtPass1.ClientID %>").value = null;
document.getElementById("<%=txtPass2.ClientID %>").value = null;
document.getElementById("<%=txtmail.ClientID %>").value=null;
}
</script>
function userValid() {
var Name, pass, gender, conpass, EmailId, emailExp;
Name = document.getElementById('<%=txtUserId.ClientID %>').value;
gender = document.getElementById("<%=ddlType.ClientID %>").value;
pass = document.getElementById("<%=txtPass1.ClientID %>").value;
conpass = document.getElementById("<%=txtPass2.ClientID %>").value;
EmailId = document.getElementById("<%=txtmail.ClientID %>").value;
emailExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([com\co\.\in])+$/;
if (Name == '' && gender == 0 && pass == '' && conpass == '' && EmailId == '') {
alert("Please Enter All Fields");
return false;
}
if (Name == '') {
alert("Please Enter Login ID");
return false;
}
if (gender == 0) {
alert("Please Select gender");
return false;
}
if (pass == '') {
alert("Please Enter Password");
return false;
}
if (pass != '' && conpass == '') {
alert("Please Confirm Password");
return false;
}
if (pass != conpass) {
alert("Password not match");
return false;
}
if (EmailId == '') {
alert("Email Id Is Required");
return false;
}
if (EmailId != '') {
if (!EmailId.match(emailExp)) {
alert("Invalid Email Id");
return false;
}
}
return true;
}
function clearAllFeilds() {
document.getElementById('<%=txtUserId.ClientID %>').value = null;
document.getElementById("<%=ddlType.ClientID %>").value = null;
document.getElementById("<%=txtPass1.ClientID %>").value = null;
document.getElementById("<%=txtPass2.ClientID %>").value = null;
document.getElementById("<%=txtmail.ClientID %>").value=null;
}
</script>
Code Behind .cs file
public class CommonShared
{
public enum PageMode
{
Insert=0,
Update=1
}
}
Before Page Load Event Write this
public CommonShared.PageMode PageMode
{
get
{
if (ViewState["Update"] != null)
{
return (CommonShared.PageMode)ViewState["Update"];
}
return CommonShared.PageMode.Insert;
}
set
{
ViewState["Update"] = value;
}
}
btn-Save PageMode Use
protected void btnSave_Click(object sender, EventArgs e)
{
bool exist;
if (PageMode==CommonShared.PageMode.Insert)
{
SaveEmployee();
BindGridview();
}
else if (PageMode==CommonShared.PageMode.Update)
{
exist=EmployeeManagement.IsExistFirstName(txtFname.Text.Trim(),Convert.ToInt32(hfId.Value));
if (exist)
{
UpdateEmployee();
BindGridview();
Clear();
btnSave.Text = "Save";
PageMode = CommonShared.PageMode.Insert;
}
else
lblMessage.Text = "First Name Already Exist.Please Enter Unique Firstname";
}
}
gvEmployee_RowCommand
protected void gvEmployee_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int id;
Employee objEmployee = new Employee();
GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
if (e.CommandName == "cmdEdit")
{
LinkButton lnkEdit = (LinkButton)row.FindControl("lnkEdit");
id = Convert.ToInt32(lnkEdit.CommandArgument);
objEmployee = EmployeeManagement.FecthRecordbyPrimeryKey(id);
txtFname.Text = objEmployee.FirstName;
txtMname.Text = objEmployee.MiddleName;
txtLname.Text = objEmployee.LastName;
txtMobile.Text = objEmployee.Mobile;
ddlCategory.SelectedValue = (objEmployee.EmployeeCategoryID.ToString());
txtSal.Text = objEmployee.Salary.ToString();
txtAddress.Text = objEmployee.Address;
hfId.Value = objEmployee.EmployeeId.ToString();
PageMode = CommonShared.PageMode.Update;
btnSave.Text = "Update";
}
else if (e.CommandName == "cmdDelete")
{
LinkButton lnkDelete = (LinkButton)row.FindControl("lnkDelete");
id = Convert.ToInt32(lnkDelete.CommandArgument);
EmployeeManagement.Delete(id);
BindGridview();
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);
}
}
gvEmployee_RowDataBound
protected void gvEmployee_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView dr = (DataRowView)e.Row.DataItem;
Label lblname = e.Row.FindControl("lblName") as Label;
//lblname.Text = string.Concat(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "FirstName")), " ",Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MiddleName")), " ",Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LastName")));
lblname.Text = string.Concat(Convert.ToString(dr["FirstName"]), " ", Convert.ToString(dr["MiddleName"]), " ", Convert.ToString(dr["LastName"]));
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);
}
}
Image Uploader
protected void btnupload_Click(object sender, EventArgs e)
{
try
{
//Captcha1.ValidateCaptcha(txtcaptcha.Text);
//if (Captcha1.UserValidated)
//{
txtcaptcha.Text = "";
if(Page.IsValid)
{
ds = new DataSet();
String p = Server.MapPath("").Replace("JobSeeker", "Upload_Resume");
Pathname = p + "/" + resume;//(Here Resume Comming from Database )
if (Pathname != null && Pathname != string.Empty)
{
if (File.Exists(Pathname))
{
File.Delete(Pathname);
}
}
string filename = Path.GetFileName(FileUpload1.FileName);
filename = filename.Replace(" ", "_");
string extenstion = Path.GetExtension(filename);
HttpFileCollection filcollection = Request.Files;
ArrayList tmplist;
ArrayList list = new ArrayList();
string resumename = string.Empty;
Int16 i = 1;
string[] files;
tmplist = new ArrayList();
files = Directory.GetFiles(p);
foreach (string fn in files)
{
resumename = Path.GetFileName(fn);
tmplist.Add(resumename);
}
resumename = filename;
Up:
if (tmplist.Contains(filename))
{
filename = resumename.Substring(0, resumename.LastIndexOf('.'));
filename = filename + "_" + i + extenstion;
i++;
goto Up;
}
FileUpload1.SaveAs(p + "/" + filename);
c1.SaveData("Update tblClientJobSeeker set Resume_name='" + filename + "' where UserId=" + Uid + "");
//Server.TransferRequest(
//Server.Transfer("JobSeeker/Home.aspx");
//Response.Redirect("~/Index.aspx");
Response.AppendHeader("Refresh", "0");
}
else
{
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "InValid";
}
}
catch (Exception ex)
{
Response.Write("<html><script>alert('Opps!!Error Occured:-" + ex.Message + "')</script></html>");
}
//Response.Redirect(Server.MapPath("") + "/Home.aspx");
}
Doweload File
protected void lnkresume_Click(object sender, EventArgs e)
{
try
{
string pathname = Server.MapPath("~/Upload_Resume/" + resume);
HttpResponse response = HttpContext.Current.Response;
FileStream fs = File.OpenRead(pathname);
MemoryStream ms = new MemoryStream();
ms.SetLength(fs.Length);
fs.Read(ms.GetBuffer(), 0, (int)fs.Length);
response.Clear();
response.AddHeader("Content-disposition", "attachment; filename=" + resume);
response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
response.BinaryWrite(ms.ToArray());
//response.TransmitFile(pathname);
response.Flush();
response.Close();
response.End();
//Response.Redirect("~/Upload_Resume/" + resume);
//WebClient req= new WebClient();
//HttpResponse response = HttpContext.Current.Response;
//response.Clear();
//response.ClearContent();
//response.ClearHeaders();
//response.Buffer = true;
//response.AppendHeader("content-disposition", "attachment;filename=\"" + pathname + "\"");
//byte[] data = req.DownloadData(pathname);
//response.BinaryWrite(data);
//response.End();
//if (lnkresume.Text.EndsWith(".doc"))
//{
// Pathname = Server.MapPath("~/Upload_Resume/" + resume);
// Response.ContentType = "application/doc";
// Response.AddHeader("content-disposition", "attachment;filename=" + resume);
// Response.Flush();
// Response.TransmitFile(Server.MapPath("~/Upload_Resume/") + resume);
//}
//else if (lnkresume.Text.EndsWith(".docx"))
//{
// Pathname = Server.MapPath("~/Upload_Resume/" + resume);
// Response.ContentType = "application/doc";
// Response.AddHeader("content-disposition", "attachment;filename=" + resume);
// Response.Flush();
// Response.TransmitFile(Server.MapPath("~/Upload_Resume/") + resume);
// Response.End();
//}
}
catch (Exception ex)
{
Response.Write("<html><script>alert('Opps!!Error Occured:-" + ex.Message + "')</script></html>");
}
}