<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8393828311730797780</id><updated>2012-02-16T02:34:22.489-08:00</updated><category term='bo'/><title type='text'>Gajula Mahesh Kumar</title><subtitle type='html'>To stay ahead, you must have your next idea waiting in the wings.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gajulamaheshkumar.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-1596251979337541803</id><published>2010-08-17T22:19:00.000-07:00</published><updated>2010-08-17T22:35:46.374-07:00</updated><title type='text'>View Doctor Details Webpage</title><content type='html'>&lt;span style="color: rgb(204, 0, 0); font-weight: bold; font-style: italic;"&gt;Doctor Details&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0); font-weight: bold;"&gt;Gridview&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;asp:GridView&lt;/span&gt; ID="gvDoctors" runat="server" AutoGenerateColumns="false" AllowPaging="true"&lt;br /&gt;                                                                                        PageSize="5" Width="100%" GridLines="Both" OnRowDataBound="gvDoctors_RowDataBound"&lt;br /&gt;                                                                                        AllowSorting="true" OnSelectedIndexChanging="gvDoctors_SelectedIndexChanging"&lt;br /&gt;                                                                                        OnSorting="gvDoctors_Sorting"&gt;&lt;br /&gt;                                                                                       &lt;br /&gt;                                                                                       &lt;br /&gt;&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;Columns&lt;/span&gt;&gt;&lt;br /&gt;&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;asp:TemplateField&lt;span style="color: rgb(0, 0, 0);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="FirstName" HeaderText="First Name" SortExpression="FirstName"&lt;br /&gt;                                                                                                HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="LastName" HeaderText="Last Name" SortExpression="LastName"&lt;br /&gt;                                                                                                HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="City" HeaderText="City" SortExpression="City" HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="State" HeaderText="State" SortExpression="State" HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"&lt;br /&gt;                                                                                                HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="Email" HeaderText="Email" SortExpression="Email" HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="HomePhone" HeaderText="Home Phone" SortExpression="HomePhone"&lt;br /&gt;                                                                                                HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:BoundField DataField&lt;/span&gt;="LicenceNumber" HeaderText="Licence Number" SortExpression="LicenceNumber"&lt;br /&gt;                                                                                                HeaderStyle-CssClass="name" /&gt;&lt;br /&gt;                                                                                            &gt;%-- &gt;asp:TemplateField ItemStyle-CssClass="hyperlink"&gt;&lt;br /&gt;                                                                                        &gt;&lt;span style="color: rgb(51, 51, 255);"&gt;ItemTemplate&lt;/span&gt;&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:HyperLink&lt;/span&gt; ID="hlnkView" runat="server" CssClass="hyperlink" NavigateUrl='&lt;%#String.Concat("/AMSWeb/ViewDoctors.aspx?stat=doct&amp;amp;did=",Eval("doctorid")) %&gt;'&gt;View&lt;/asp:HyperLink&gt;&lt;br /&gt;                                                                                            |&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:HyperLink&lt;/span&gt; ID="hlnkEdit" runat="server" CssClass="hyperlink" NavigateUrl='&gt;%#String.Concat("/AMSWeb/ModifyDoctor.aspx?stat=doct&amp;amp;did=",Eval("doctorid")) %&gt;'&gt;Edit&gt;/asp:HyperLink&gt;&lt;br /&gt;                                                                                            |&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:HyperLink&lt;/span&gt; ID="HyperLink2" runat="server" CssClass="hyperlink" NavigateUrl='&gt;%#String.Concat("/AMSWeb/doctorappointments.aspx?stat=doct&amp;amp;did=",Eval("doctorid")) %&gt;'&lt;Appointments&lt;br /&gt;                                                                                            &gt;/asp:HyperLink&gt;&lt;br /&gt;                                                                                            &gt;&lt;span style="color: rgb(153, 51, 153);"&gt;asp:HyperLink&lt;/span&gt; ID="HyperLink1" runat="server" CssClass="hyperlink" NavigateUrl='&gt;%#String.Concat("/AMSWeb/doctorschedule.aspx?stat=doct&amp;amp;did=",Eval("doctorid")) %&gt;'&lt;br /&gt;                                                                                                Visible="false"&gt;Set Schedule&gt;/asp:HyperLink&gt;&lt;br /&gt;                                                                                        &gt;/&lt;span style="color: rgb(51, 51, 255);"&gt;ItemTemplate&lt;/span&gt;&gt;&lt;br /&gt;                                                                                    &gt;/&lt;span style="color: rgb(51, 51, 255);"&gt;asp:TemplateField&lt;/span&gt;&gt;--%&gt;&lt;br /&gt;                                                                                        &gt;/&lt;span style="color: rgb(51, 102, 255);"&gt;Columns&lt;/span&gt;&gt;&lt;br /&gt;                                                                                    &gt;/&lt;span style="color: rgb(51, 51, 255);"&gt;asp:GridView&lt;/span&gt;&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;buttons&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;input id="btnView" name="btnView" class="&lt;span style="color: rgb(153, 153, 153);"&gt;submitbutton&lt;/span&gt;" type="button" value="&lt;span style="color: rgb(51, 51, 255);"&gt;View&lt;/span&gt;"&lt;br /&gt;                                                                                onclick="return ViewDoctor();" /&gt;&lt;br /&gt;                                                                            &lt;br /&gt;                                                                            &gt;input id="btnEdit" name="btnEdit" class="submitbutton" type="button" value="&lt;span style="color: rgb(51, 51, 255);"&gt;Edit&lt;/span&gt;"&lt;br /&gt;                                                                                onclick="return EditDoctor();" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-1596251979337541803?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1596251979337541803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1596251979337541803'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/view-doctor-details-webpage.html' title='View Doctor Details Webpage'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-8316798102871589746</id><published>2010-08-17T22:03:00.000-07:00</published><updated>2010-08-17T22:14:34.664-07:00</updated><title type='text'>Doctor Webpage.cs</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(204, 0, 0); font-style: italic;"&gt;Doctor.CS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;br /&gt;INSERT &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Xml.Linq;&lt;br /&gt;using AMS.BO;&lt;br /&gt;using AMS.BLL;&lt;br /&gt;&lt;br /&gt;public partial class adddoctor : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            GetSpecilizations();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void GetSpecilizations()&lt;br /&gt;    {&lt;br /&gt;        DoctorsBLL objCPBLL = new DoctorsBLL();&lt;br /&gt;        DataSet ds = objCPBLL.GetSpecilizations();&lt;br /&gt;        ddlSpecializationId.DataSource = ds;&lt;br /&gt;        ddlSpecializationId.DataBind();&lt;br /&gt;    }&lt;br /&gt;    protected void btnSubmit_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        DoctorsBLL objCPBLL = new DoctorsBLL();&lt;br /&gt;        UsersBLL objUserBLL = new UsersBLL();&lt;br /&gt;        DoctorsBO objDoctorBO = new DoctorsBO();&lt;br /&gt;        UsersBO objUserBO = new UsersBO();&lt;br /&gt;        int doctorid = -1;&lt;br /&gt;        int userid = AddUser();&lt;br /&gt;&lt;br /&gt;        if (userid != 0)&lt;br /&gt;        {&lt;br /&gt;            doctorid = AddDoctor(userid);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if (doctorid == -1)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            objUserBO.Type = "Delete";&lt;br /&gt;            objUserBLL.UsersOperations(objUserBO);&lt;br /&gt;&lt;br /&gt;            string alert = "&gt;script language=javascript&gt;alert('Error Occured Doctor Details..');&gt;/script&gt;";&lt;br /&gt;            Page.ClientScript.RegisterStartupScript(typeof(Page), "Alert", alert);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            string alert = "&gt;script language=javascript&gt;alert('Doctor Successfully Inserted');&gt;/script&gt;";&lt;br /&gt;            Response.Write(alert);&lt;br /&gt;            //Page.ClientScript.RegisterStartupScript(typeof(Page), "Alert", alert);&lt;br /&gt;            Response.Redirect("/AMSWeb/doctors.aspx");&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private int AddUser()&lt;br /&gt;    {&lt;br /&gt;        UsersBLL objBLL = new UsersBLL();&lt;br /&gt;        UsersBO objBO = new UsersBO();&lt;br /&gt;        objBO.UserName = txtUserName.Text;&lt;br /&gt;        objBO.Password = txtPassword.Text;&lt;br /&gt;        objBO.Role = 1;&lt;br /&gt;        objBO.Email = txtEmail.Text;&lt;br /&gt;        if (chkStatus.Checked)&lt;br /&gt;        {&lt;br /&gt;            objBO.Status = 1;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            objBO.Status = 0;&lt;br /&gt;        }&lt;br /&gt;        objBO.EnteredDate = Convert.ToString(DateTime.Now);&lt;br /&gt;        objBO.Type = "Insert";&lt;br /&gt;        objBO = objBLL.UsersOperations(objBO);&lt;br /&gt;        if (objBO.NewUserId != 0)&lt;br /&gt;        {&lt;br /&gt;            return objBO.NewUserId;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;            return 0;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    private int AddDoctor(int userid)&lt;br /&gt;    {&lt;br /&gt;        DoctorsBLL objBLL = new DoctorsBLL();&lt;br /&gt;        DoctorsBO objBO = new DoctorsBO();&lt;br /&gt;        objBO.UserId = userid;&lt;br /&gt;        objBO.FirstName = txtFirstName.Text;&lt;br /&gt;        objBO.LastName = txtLastName.Text;&lt;br /&gt;        objBO.MiddleName = txtMiddleName.Text;&lt;br /&gt;        objBO.SSN = txtSSN.Text;&lt;br /&gt;        objBO.DOB = txtDOB.Text;&lt;br /&gt;        objBO.Gender = rdolstGender.SelectedItem.Text;&lt;br /&gt;        objBO.Age = Convert.ToInt32(txtAge.Text);&lt;br /&gt;        objBO.Address = txtAddress.Text;&lt;br /&gt;        objBO.City = txtCity.Text;&lt;br /&gt;        objBO.State = txtState.Text;&lt;br /&gt;        objBO.ZipCode = txtZipCode.Text;&lt;br /&gt;        objBO.Email = txtEmail.Text;&lt;br /&gt;        objBO.HomePhone = txtHomePhone.Text;&lt;br /&gt;        objBO.WorkPhone = txtWorkPhone.Text;&lt;br /&gt;        objBO.Mobile = txtMobile.Text;&lt;br /&gt;        objBO.Fax = txtFax.Text;&lt;br /&gt;        objBO.SpecilizationId = Convert.ToInt32(ddlSpecializationId.SelectedItem.Value);&lt;br /&gt;        objBO.RegistrationNumber = txtRegistrationNo.Text;&lt;br /&gt;        objBO.LicenceNumber = txtLicenceNo.Text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        objBO.Type = "Insert";&lt;br /&gt;        objBO = objBLL.DoctorOperations(objBO);&lt;br /&gt;        if (objBO.DoctorId == 1)&lt;br /&gt;            return 1;&lt;br /&gt;        else&lt;br /&gt;            return -1;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;UPDATE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Xml.Linq;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using AMS.BO;&lt;br /&gt;using AMS.BLL;&lt;br /&gt;&lt;br /&gt;public partial class ClaimantAdministrator : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    int ClaimantAdminID&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            int claimantAdminID = 0;&lt;br /&gt;&lt;br /&gt;            if (Request.QueryString["cid"] != null &amp;amp;&amp;amp; Request.QueryString["cid"].Length &gt; 0)&lt;br /&gt;            {&lt;br /&gt;                claimantAdminID = Convert.ToInt32(Request.QueryString["cid"]);&lt;br /&gt;                Session["claimantID"] = claimantAdminID;&lt;br /&gt;            }&lt;br /&gt;            else if (Session["claimantID"] != null)&lt;br /&gt;                claimantAdminID = Convert.ToInt32(Session["cid"]);&lt;br /&gt;            return claimantAdminID;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        btnSubmit.Attributes.Add("onclick", "return validate();");&lt;br /&gt;&lt;br /&gt;        if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            GetUSStates();&lt;br /&gt;            if (ClaimantAdminID != 0)&lt;br /&gt;                DisplayCalimantAdministrator();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void DisplayCalimantAdministrator()&lt;br /&gt;    {&lt;br /&gt;        ClaimantAdminInformationBLL objCABLL = new ClaimantAdminInformationBLL();&lt;br /&gt;        ClaimantAdminInformationBO objCABO = new ClaimantAdminInformationBO();&lt;br /&gt;        objCABO.Type = "SelectByClaimantAdminID";&lt;br /&gt;        objCABO.ClaimantAdminID = ClaimantAdminID;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;        objCABLL.ClaimantAdminOperations(objCABO);&lt;br /&gt;        ds = objCABO.GetUSStates;&lt;br /&gt;        if (ds.Tables[0].Rows.Count &gt; 0)&lt;br /&gt;        {&lt;br /&gt;            DataTable dt = ds.Tables[0];&lt;br /&gt;            ViewState["ClaimantAdminID"] = ds.Tables[0].Rows[0]["ClaimantAdminID"].ToString();&lt;br /&gt;            txtClaimantAdminName.Text = ds.Tables[0].Rows[0]["ClaimantAdminName"].ToString();&lt;br /&gt;            txtClaimantAdminAddress.Text = ds.Tables[0].Rows[0]["Address"].ToString();&lt;br /&gt;            txtClaimantAdminCity.Text = ds.Tables[0].Rows[0]["City"].ToString();&lt;br /&gt;            ddlState.Text = ds.Tables[0].Rows[0]["State"].ToString();&lt;br /&gt;            txtClaimantAdminPhone.Text = ds.Tables[0].Rows[0]["PhoneNo"].ToString();&lt;br /&gt;            txtClaimantAdminZipCode.Text = ds.Tables[0].Rows[0]["ZipCode"].ToString();&lt;br /&gt;            txtClaimantAdminFax.Text = ds.Tables[0].Rows[0]["Fax"].ToString();&lt;br /&gt;            txtClaimantAdminEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString();&lt;br /&gt;&lt;br /&gt;            txtCPName.Text = ds.Tables[0].Rows[0]["ContactPersonName"].ToString();&lt;br /&gt;            txtCPSSN.Text = ds.Tables[0].Rows[0]["ContactPersonSSN"].ToString();&lt;br /&gt;            txtCPTitle.Text = ds.Tables[0].Rows[0]["ContactPersonTitle"].ToString();&lt;br /&gt;            txtCPPhone.Text = ds.Tables[0].Rows[0]["ContactPersonPhoneNo"].ToString();&lt;br /&gt;            txtCPMobile.Text = ds.Tables[0].Rows[0]["ContactPersonMobileNo"].ToString();&lt;br /&gt;            txtCPEmail.Text = ds.Tables[0].Rows[0]["ContactPersonEmail"].ToString();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    private void GetUSStates()&lt;br /&gt;    {&lt;br /&gt;        ClaimantAdminInformationBLL objBLL = new ClaimantAdminInformationBLL();&lt;br /&gt;        ClaimantAdminInformationBO objBO = new ClaimantAdminInformationBO();&lt;br /&gt;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;        ds = objBLL.GetUSStates();&lt;br /&gt;        ddlState.DataSource = ds;&lt;br /&gt;&lt;br /&gt;        ddlState.DataTextField = "USStateName";&lt;br /&gt;        ddlState.DataValueField = "USStateCd";&lt;br /&gt;        ddlState.DataBind();&lt;br /&gt;&lt;br /&gt;        ddlState.Items.FindByText("California").Selected = true;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected void btnSubmit_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        ClaimantAdminInformationBLL objCABLL = new ClaimantAdminInformationBLL();&lt;br /&gt;        ClaimantAdminInformationBO objCABO = new ClaimantAdminInformationBO();&lt;br /&gt;        objCABO.ClaimantAdminName = txtClaimantAdminName.Text;&lt;br /&gt;        objCABO.Address = txtClaimantAdminAddress.Text;&lt;br /&gt;        objCABO.City = txtClaimantAdminCity.Text;&lt;br /&gt;        objCABO.State = ddlState.SelectedItem.Value;&lt;br /&gt;        objCABO.ZipCode = txtClaimantAdminZipCode.Text;&lt;br /&gt;        objCABO.PhoneNo = txtClaimantAdminPhone.Text;&lt;br /&gt;        objCABO.Fax = txtClaimantAdminFax.Text;&lt;br /&gt;        objCABO.Email = txtClaimantAdminEmail.Text;&lt;br /&gt;        objCABO.ContactPersonName = txtCPName.Text;&lt;br /&gt;        objCABO.ContactPersonTitle = txtCPTitle.Text;&lt;br /&gt;        objCABO.ContactPersonSSN = txtCPSSN.Text;&lt;br /&gt;        objCABO.ContactPersonPhoneNo = txtCPPhone.Text;&lt;br /&gt;        objCABO.ContactPersonMobileNo = txtCPMobile.Text;&lt;br /&gt;        objCABO.ContactPersonEmail = txtCPEmail.Text;&lt;br /&gt;&lt;br /&gt;        if (ViewState["ClaimantAdminID"] == null)&lt;br /&gt;            objCABO.Type = "Insert";&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            objCABO.Type = "Update";&lt;br /&gt;            objCABO.ClaimantAdminID = Convert.ToInt32(ViewState["ClaimantAdminID"]);&lt;br /&gt;        }&lt;br /&gt;        objCABLL.ClaimantAdminOperations(objCABO);&lt;br /&gt;&lt;br /&gt;        Response.Redirect("ClaimantAdministrator.aspx?stat=comp");&lt;br /&gt;&lt;br /&gt;        //if (objCABO.ClaimantAdminID == 0)&lt;br /&gt;        //{&lt;br /&gt;        //    string str = "&lt;script language="'javascript'"&gt;alert('Details submitted successfully');&lt;/script&gt;";&lt;br /&gt;        //    Page.ClientScript.RegisterStartupScript(typeof(Page), "success", str);&lt;br /&gt;        //}&lt;br /&gt;        //else&lt;br /&gt;        //{&lt;br /&gt;        //    string str = "&lt;script language="'javascript'"&gt;alert('Details updated successfully');&lt;/script&gt;";&lt;br /&gt;        //    Page.ClientScript.RegisterStartupScript(typeof(Page), "success", str);&lt;br /&gt;        //}&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-8316798102871589746?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8316798102871589746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8316798102871589746'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/doctor-webpagecs.html' title='Doctor Webpage.cs'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-8984132120809836618</id><published>2010-08-17T21:54:00.000-07:00</published><updated>2010-08-17T22:03:25.871-07:00</updated><title type='text'>Doctor Webpage</title><content type='html'>&lt;span style="font-style: italic; font-weight: bold; color: rgb(255, 0, 0);"&gt;Doctor Add page &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;textbox&lt;/span&gt;&lt;br /&gt;&gt;asp:TextBox ID="txtFirstName" runat="server" CssClass="TextBox"&gt;&gt;/asp:TextBox&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rediobutton   &lt;/span&gt;                                                       &lt;br /&gt;&gt;asp:RadioButtonList ID="rdolstGender" runat="server"&lt;br /&gt;                       RepeatDirection="Horizontal"&gt;&lt;br /&gt;                       &gt;asp:ListItem Selected="True"&gt;Male&gt;/asp:ListItem&gt;&lt;br /&gt;                       &gt;asp:ListItem&gt;Female&gt;/asp:ListItem&gt;&lt;br /&gt;                   &gt;/asp:RadioButtonList&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dropdownbutton&lt;/span&gt;&lt;br /&gt;&gt;asp:DropDownList ID="ddlSpecializationId" runat="server"&lt;br /&gt;                       DataTextField="Specilization" DataValueField="SpecilizationId"&lt;br /&gt;                       CssClass="TextBox"&gt;&lt;br /&gt;                       &gt;asp:ListItem Value="-1" &gt;Select Specialization&gt;/asp:ListItem&gt;&lt;br /&gt;                       &gt;asp:ListItem Value="0"&gt;Cardiologist&gt;/asp:ListItem&gt;&lt;br /&gt;                       &gt;asp:ListItem Value="1"&gt;Physiotheraphist&gt;/asp:ListItem&gt;&lt;br /&gt;                       &gt;asp:ListItem Value="2"&gt;Dermatologist&gt;/asp:ListItem&gt;&lt;br /&gt;                       &gt;asp:ListItem Value="3"&gt;Gynaecologist&gt;/asp:ListItem&gt;&lt;br /&gt;                   &gt;/asp:DropDownList&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;button&lt;/span&gt;&lt;br /&gt;&gt;asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="Button"&lt;br /&gt;                            onclick="btnSubmit_Click" /&gt;&lt;br /&gt;                   &lt;br /&gt;&gt;asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="Button"&lt;br /&gt;                        CausesValidation="False" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-8984132120809836618?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8984132120809836618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8984132120809836618'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/doctor-webpage.html' title='Doctor Webpage'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6842049603579109454</id><published>2010-08-17T21:40:00.000-07:00</published><updated>2010-08-17T21:47:52.690-07:00</updated><title type='text'>DLL (Data Logic Layar )</title><content type='html'>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 0, 0);"&gt;DoctorDAL &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using AMS.BO;&lt;br /&gt;using AMS.DAL;&lt;br /&gt;&lt;br /&gt;namespace AMS.BLL&lt;br /&gt;{&lt;br /&gt;  public class DoctorsBLL&lt;br /&gt;   {&lt;br /&gt;      public DoctorsBO DoctorOperations(DoctorsBO objBO)&lt;br /&gt;      {&lt;br /&gt;          DoctorsDAL objDAL = new DoctorsDAL();&lt;br /&gt;          return objDAL.DoctorOperations(objBO);&lt;br /&gt;      }&lt;br /&gt;      public DataSet GetSpecilizations()&lt;br /&gt;      {&lt;br /&gt;          DoctorsDAL objDAL = new DoctorsDAL();&lt;br /&gt;          return objDAL.GetSpecilizations();&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6842049603579109454?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6842049603579109454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6842049603579109454'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/dll-data-logic-layar.html' title='DLL (Data Logic Layar )'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-5490857932956808905</id><published>2010-08-17T21:20:00.000-07:00</published><updated>2010-08-17T21:38:44.833-07:00</updated><title type='text'>DAL ( DATA ACCESS LAYAER )</title><content type='html'>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 102);font-family:arial;" &gt;DoctorDAL &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using AMS.BO;&lt;br /&gt;&lt;br /&gt;namespace AMS.DAL&lt;br /&gt;{&lt;br /&gt;  public class DoctorsDAL:DALTemplateClass&lt;br /&gt;  {&lt;br /&gt;      private SqlConnection myConn;&lt;br /&gt;      public DoctorsBO DoctorOperations(DoctorsBO objBO)&lt;br /&gt;      {&lt;br /&gt;          // Create Instance of Connection and Command Object&lt;br /&gt;&lt;br /&gt;          myConn = new     SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["AMSDB"]);&lt;br /&gt;          SqlCommand myComm = new SqlCommand("AMS_Doctors_Operations", myConn);&lt;br /&gt;          SqlDataAdapter da = new SqlDataAdapter();&lt;br /&gt;&lt;br /&gt;          // Mark the Command as a SPROC&lt;br /&gt;&lt;br /&gt;          myComm.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;          myComm.Parameters.AddWithValue("@DoctorId", objBO.DoctorId);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Hid", objBO.Hid);&lt;br /&gt;          myComm.Parameters.AddWithValue("@UserId", objBO.UserId);&lt;br /&gt;          myComm.Parameters.AddWithValue("@SalutationId", objBO.SalutationId);&lt;br /&gt;          myComm.Parameters.AddWithValue("@FirstName", objBO.FirstName);&lt;br /&gt;          myComm.Parameters.AddWithValue("@LastName", objBO.LastName);&lt;br /&gt;          myComm.Parameters.AddWithValue("@MiddleName", objBO.MiddleName);&lt;br /&gt;          myComm.Parameters.AddWithValue("@SSN", objBO.SSN);&lt;br /&gt;          myComm.Parameters.AddWithValue("@DOB", objBO.DOB);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Gender", objBO.Gender);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Age", objBO.Age);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Address", objBO.Address);&lt;br /&gt;          myComm.Parameters.AddWithValue("@City", objBO.City);&lt;br /&gt;          myComm.Parameters.AddWithValue("@State", objBO.State);&lt;br /&gt;          myComm.Parameters.AddWithValue("@ZipCode", objBO.ZipCode);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Email", objBO.Email);&lt;br /&gt;          myComm.Parameters.AddWithValue("@HomePhone", objBO.HomePhone);&lt;br /&gt;          myComm.Parameters.AddWithValue("@WorkPhone", objBO.WorkPhone);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Mobile", objBO.Mobile);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Fax", objBO.Fax);&lt;br /&gt;          myComm.Parameters.AddWithValue("@SpecilizationId", objBO.SpecilizationId);&lt;br /&gt;          myComm.Parameters.AddWithValue("@RegistrationNumber", objBO.RegistrationNumber);&lt;br /&gt;          myComm.Parameters.AddWithValue("@LicenceNumber", objBO.LicenceNumber);&lt;br /&gt;          myComm.Parameters.AddWithValue("@Type",&lt;span style="color: rgb(102, 51, 255);"&gt; objBO.Type)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;          // Open the connection and execute the Command       &lt;br /&gt;&lt;br /&gt;          try&lt;br /&gt;          {&lt;br /&gt;&lt;br /&gt;              myConn.Open();&lt;br /&gt;              if (&lt;span style="color: rgb(51, 102, 255);"&gt;objBO.Type == "Insert" || objBO.Type == "Update"&lt;/span&gt;)&lt;br /&gt;              {&lt;br /&gt;&lt;br /&gt;                  myComm.ExecuteNonQuery();&lt;br /&gt;                  objBO.DoctorId = 1;&lt;br /&gt;               &lt;br /&gt;              }&lt;br /&gt;          &lt;span style="color: rgb(255, 153, 102);"&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;   if (objBO.Type == "SelectAll" || objBO.Type == "SelectById" || objBO.Type=="SelectByUserId"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;                    || objBO.Type == "SelectByHospitalId" || objBO.Type == "Search" )&lt;/span&gt;&lt;br /&gt;              {&lt;br /&gt;&lt;br /&gt;                  DataSet ds = new DataSet();&lt;br /&gt;                  da.SelectCommand = myComm;&lt;br /&gt;                  da.Fill(ds);&lt;br /&gt;                  objBO.DoctorsDS = ds;&lt;br /&gt;&lt;br /&gt;              }&lt;br /&gt;              return objBO;&lt;br /&gt;          }&lt;br /&gt;          catch (Exception ex)&lt;br /&gt;          {&lt;br /&gt;              MessageDescription = ex.Message;&lt;br /&gt;              return null;&lt;br /&gt;          }&lt;br /&gt;          finally&lt;br /&gt;          {&lt;br /&gt;              myConn.Close();&lt;br /&gt;              myComm.Dispose();&lt;br /&gt;              da.Dispose();&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;     &lt;span style="color: rgb(255, 0, 0);"&gt; public DataSet GetSpecilizations()&lt;/span&gt;&lt;br /&gt;      {&lt;br /&gt;          // Create Instance of Connection and Command Object&lt;br /&gt;&lt;br /&gt;          myConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["AMSDB"]);&lt;br /&gt;          SqlCommand myComm = new SqlCommand("AMS_Specializations_Operations", myConn);&lt;br /&gt;          SqlDataAdapter da = new SqlDataAdapter();&lt;br /&gt;          // Mark the Command as a SPROC&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;          // Open the connection and execute the Command       &lt;br /&gt;&lt;br /&gt;          try&lt;br /&gt;          {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;              DataSet ds = new DataSet();&lt;br /&gt;              da.SelectCommand = myComm;&lt;br /&gt;              da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;              return ds;&lt;br /&gt;          }&lt;br /&gt;          catch (Exception ex)&lt;br /&gt;          {&lt;br /&gt;              MessageDescription = ex.Message;&lt;br /&gt;              return null;&lt;br /&gt;          }&lt;br /&gt;          finally&lt;br /&gt;          {&lt;br /&gt;              myConn.Close();&lt;br /&gt;              myComm.Dispose();&lt;br /&gt;              da.Dispose();&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold; font-style: italic;"&gt;Connection DB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;namespace AMS.DAL&lt;br /&gt;{&lt;br /&gt;   public class ConnectionDB&lt;br /&gt;   {&lt;br /&gt;       private static SqlConnection _dbConnection;&lt;br /&gt;     &lt;br /&gt;       public static void&lt;span style="color: rgb(51, 51, 255);"&gt; CloseConnection()&lt;/span&gt;&lt;br /&gt;       {&lt;br /&gt;           if (_dbConnection.State != ConnectionState.Closed)&lt;br /&gt;           {&lt;br /&gt;               _dbConnection.Close();&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public static SqlConnection&lt;span style="color: rgb(51, 51, 255);"&gt; GetConnection()&lt;/span&gt;&lt;br /&gt;       {&lt;br /&gt;           _dbConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["AMSDB"]);&lt;br /&gt;           _dbConnection.Open();&lt;br /&gt;           return _dbConnection;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0); font-style: italic; font-weight: bold;"&gt;web.config&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;appSettings&gt;&lt;br /&gt;       &gt;add key="AMSDB" value="server=SYS;User Id=sa;Password=123456;database=AMSDBNew;Connection Timeout=10000;"/&gt;&lt;br /&gt;       &gt;!--&lt;add key="AMSDB" value="server=Server;User Id=sa;Password=123456;database=AMSDBNEW;Connection Timeout=10000;"&gt;&lt;/add&gt;--&gt;&lt;br /&gt;       &gt;add key="autoSuggestConnectionString" value="server=.\SQLEXPRESS;Integrated Security=SSPI;database=northwind;provider=SQLNCLI.1"/&gt;&lt;br /&gt;       &gt;add key="DocId" value="1"/&gt;&lt;br /&gt;       &gt;add key="HId" value="2"/&gt;&lt;br /&gt;       &gt;add key="CompanyID" value="31"/&gt;&lt;br /&gt;       &gt;add key="ContactPersonID" value="23"/&gt;&lt;br /&gt;       &gt;add key="PhysicalPathofPDF" value="D:\AMS\\AMSWeb\\Documents\\"/&gt;&lt;br /&gt;       &gt;!-- EMail Credentials --&gt;&lt;br /&gt;       &gt;add key="networkCredentialMailId" value="gajulamk@gmail.com"/&gt;&lt;br /&gt;       &gt;add key="networkCredentialMailPassword" value="gajula"/&gt;&lt;br /&gt;       &gt;add key="defaultFromMailId" value="ams.gajulamk@gmail.com"/&gt;&lt;br /&gt;       &gt;add key="smtpClient" value="smtp.gmail.com"/&gt;&lt;br /&gt;       &gt;add key="port" value="587"/&gt;&lt;br /&gt;       &gt;!-- End EMail--&gt;&lt;br /&gt;   &gt;/appSettings&gt;&lt;br /&gt;   &gt;connectionStrings/&gt;&lt;br /&gt;   &gt;system.web&gt;&lt;br /&gt;     &lt;br /&gt;&gt;!--&lt;br /&gt;           Set compilation debug="true" to insert debugging&lt;br /&gt;           symbols into the compiled page. Because this&lt;br /&gt;           affects performance, set this value to true only&lt;br /&gt;           during development.&lt;br /&gt;       --&gt;&lt;br /&gt;       &gt;customErrors mode="Off"/&gt;&lt;br /&gt;       &gt;compilation debug="true"&gt;&lt;br /&gt;           &gt;assemblies&gt;&lt;br /&gt;               &gt;add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;&lt;br /&gt;               &gt;add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;&lt;br /&gt;               &gt;add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;&lt;br /&gt;               &gt;add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;&lt;br /&gt;               ?add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;&lt;br /&gt;               &gt;add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;&lt;br /&gt;               &lt;add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"&gt;&lt;br /&gt;           &gt;/assemblies&gt;&lt;br /&gt;       &gt;/compilation&gt;&lt;/add&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-5490857932956808905?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5490857932956808905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5490857932956808905'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/dal-data-access-layaer.html' title='DAL ( DATA ACCESS LAYAER )'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-4471222290572718420</id><published>2010-08-17T21:05:00.000-07:00</published><updated>2010-08-17T21:19:33.706-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bo'/><title type='text'>BO ( Bussiness Objectives )</title><content type='html'>&lt;span style="font-weight: bold; font-style: italic; font-family: arial; color: rgb(255, 0, 0);"&gt;DoctorBO first &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;namespace AMS.BO&lt;br /&gt;{&lt;br /&gt;    public class DoctorsBO:ProfileBO&lt;br /&gt;    {&lt;br /&gt;        private int _DoctorId;&lt;br /&gt;        public int DoctorId&lt;br /&gt;        {&lt;br /&gt;            get { return _DoctorId; }&lt;br /&gt;            set { _DoctorId = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _DOB;&lt;br /&gt;        public string DOB&lt;br /&gt;        {&lt;br /&gt;            get { return _DOB; }&lt;br /&gt;            set { _DOB = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _Gender;&lt;br /&gt;        public string Gender&lt;br /&gt;        {&lt;br /&gt;            get { return _Gender; }&lt;br /&gt;            set { _Gender = value; }&lt;br /&gt;        }&lt;br /&gt;        private int _Age;&lt;br /&gt;        public int Age&lt;br /&gt;        {&lt;br /&gt;            get { return _Age; }&lt;br /&gt;            set { _Age = value; }&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        private string _Address;&lt;br /&gt;        public string Address&lt;br /&gt;        {&lt;br /&gt;            get { return _Address; }&lt;br /&gt;            set { _Address = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _City;&lt;br /&gt;        public string City&lt;br /&gt;        {&lt;br /&gt;            get { return _City; }&lt;br /&gt;            set { _City = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _State;&lt;br /&gt;        public string State&lt;br /&gt;        {&lt;br /&gt;            get { return _State; }&lt;br /&gt;            set { _State = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _ZipCode;&lt;br /&gt;        public string ZipCode&lt;br /&gt;        {&lt;br /&gt;            get { return _ZipCode; }&lt;br /&gt;            set { _ZipCode = value; }&lt;br /&gt;        }&lt;br /&gt;        private int _SpecilizationId;&lt;br /&gt;        public int SpecilizationId&lt;br /&gt;        {&lt;br /&gt;            get { return _SpecilizationId; }&lt;br /&gt;            set { _SpecilizationId = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _RegistrationNumber;&lt;br /&gt;        public string RegistrationNumber&lt;br /&gt;        {&lt;br /&gt;            get { return _RegistrationNumber; }&lt;br /&gt;            set { _RegistrationNumber = value; }&lt;br /&gt;        }&lt;br /&gt;        private string _LicenceNumber;&lt;br /&gt;        public string LicenceNumber&lt;br /&gt;        {&lt;br /&gt;            get { return _LicenceNumber; }&lt;br /&gt;            set { _LicenceNumber = value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private DataSet _DoctorsDS;&lt;br /&gt;        public DataSet DoctorsDS&lt;br /&gt;        {&lt;br /&gt;            get { return _DoctorsDS; }&lt;br /&gt;            set { _DoctorsDS = value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: arial; font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-family: arial; color: rgb(255, 0, 0);"&gt;DoctorBO Second &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;namespace AMS.BO&lt;br /&gt;{&lt;br /&gt;    public class DoctorsBO:ProfileBO&lt;br /&gt;    {&lt;br /&gt;       public int DctorID { get; set; }&lt;br /&gt;        public string DOB{ get; set; }&lt;br /&gt;        public string Gender{ get; set; }&lt;br /&gt;        public string Age{ get; set; }&lt;br /&gt;        public string Address{ get; set; }&lt;br /&gt;        public string City{ get; set; }&lt;br /&gt;        public string ToDate { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-4471222290572718420?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4471222290572718420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4471222290572718420'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/08/bo-bussiness-objectives.html' title='BO ( Bussiness Objectives )'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-5917581059503106001</id><published>2010-03-08T21:21:00.000-08:00</published><updated>2010-03-08T21:25:43.657-08:00</updated><title type='text'>Using a WPF ListView as a DataGrid</title><content type='html'>&lt;div style="text-align: justify;"&gt;Many people like to view data in a grid format of rows and columns. WPF did not come with a data grid control that automatically creates rows and columns for you based on the object you pass it. However, the WPF Toolkit can be downloaded from CodePlex.com that does contain a DataGrid control. This DataGrid gives you the ability to pass it a DataTable or a Collection class and it will automatically figure out the columns or properties and create all the columns for you and display the data.&lt;br /&gt;&lt;/div&gt;&lt;p style="text-align: justify;"&gt;The DataGrid control also supports editing and many other features that you might not always need. This means that the DataGrid does take a little more time to render the data. If you want to just display data (see Figure 1) in a grid format, then a ListView works quite well for this task. Of course, you will need to create the columns for the ListView, but with just a little generic code, you can create the columns on the fly just like the WPF Toolkit’s DataGrid.&lt;/p&gt; &lt;p&gt;&lt;img title="ListView as a DataGrid - Figure 1" alt="ListView as a DataGrid - Figure 1" src="http://www.pdsa.com/images/WPFListViewFigure1.jpg" mce_src="http://www.pdsa.com/images/WPFListViewFigure1.jpg" /&gt;&lt;/p&gt; &lt;p&gt;Figure 1: A List of Data using a ListView&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;strong&gt;A Simple ListView Control&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;The XAML below is what you would use to create the ListView shown in Figure 1. However, the problem with using XAML is you have to pre-define the columns. You cannot re-use this ListView except for “Product” data.&lt;/div&gt; &lt;p&gt;&lt;br /&gt;&gt;ListView x:Name="lstData"&lt;br /&gt;        ItemsSource="{Binding}"&gt;&lt;br /&gt;&gt;ListView.View&gt;&lt;br /&gt;  &gt;GridView&gt;&lt;br /&gt;    &gt;GridViewColumn Header="Product ID"&lt;br /&gt;                    Width="Auto"&lt;br /&gt;             DisplayMemberBinding="{Binding Path=ProductId}" /&gt;&lt;br /&gt;    &gt;GridViewColumn Header="Product Name"&lt;br /&gt;                    Width="Auto"&lt;br /&gt;             DisplayMemberBinding="{Binding Path=ProductName}" /&gt;&lt;br /&gt;    &gt;GridViewColumn Header="Price"&lt;br /&gt;                    Width="Auto"&lt;br /&gt;             DisplayMemberBinding="{Binding Path=Price}" /&gt;&lt;br /&gt;  &gt;/GridView&gt;&lt;br /&gt;&gt;/ListView.View&gt;&lt;br /&gt;&gt;/ListView&gt;&lt;/p&gt; &lt;p style="text-align: justify;"&gt;So, instead of creating the GridViewColumn’s in XAML, let’s learn to create them in code to create any amount of columns in a ListView.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Create GridViewColumn’s From Data Table&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;To display multiple columns in a ListView control you need to set its View property to a GridView collection object. You add GridViewColumn objects to the GridView collection and assign the GridView to the View property. Each GridViewColumn object needs to be bound to a column or property name of the object that the ListView will be bound to. An ADO.NET DataTable object contains a collection of columns, and these columns have a ColumnName property which you use to bind to the GridViewColumn objects.&lt;/div&gt; &lt;p style="text-align: justify;"&gt;Listing 1 shows a sample of reading and XML file into a DataSet object. After reading the data a GridView object is created. You can then loop through the DataTable columns collection and create a GridViewColumn object for each column in the DataTable. Notice the DisplayMemberBinding property is set to a new Binding to the ColumnName in the DataTable.&lt;/p&gt; &lt;p&gt;C#&lt;br /&gt;private void FirstSample()&lt;br /&gt;{&lt;br /&gt;// Read the data&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;ds.ReadXml(GetCurrentDirectory() + @"\Xml\Product.xml");&lt;br /&gt;&lt;br /&gt;// Create the GridView&lt;br /&gt;GridView gv = new GridView();&lt;/p&gt; &lt;p&gt;  // Create the GridView Columns&lt;br /&gt;foreach (DataColumn item in ds.Tables[0].Columns)&lt;br /&gt;{&lt;br /&gt;  GridViewColumn gvc = new GridViewColumn();&lt;br /&gt;  gvc.DisplayMemberBinding = new Binding(item.ColumnName);&lt;br /&gt;  gvc.Header = item.ColumnName;&lt;br /&gt;  gvc.Width = Double.NaN;&lt;br /&gt;  gv.Columns.Add(gvc);&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;  // Setup the GridView Columns&lt;br /&gt;lstData.View = gv;&lt;br /&gt;// Display the Data&lt;br /&gt;lstData.DataContext = ds.Tables[0];&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;VB.NET&lt;br /&gt;Private Sub FirstSample()&lt;br /&gt;' Read the data&lt;br /&gt;Dim ds As New DataSet()&lt;br /&gt;ds.ReadXml(GetCurrentDirectory() &amp;amp; "\Xml\Product.xml")&lt;/p&gt; &lt;p&gt;  ' Create the GridView&lt;br /&gt;Dim gv As New GridView()&lt;/p&gt; &lt;p&gt;  ' Create the GridView Columns&lt;br /&gt;For Each item As DataColumn In ds.Tables(0).Columns&lt;br /&gt;  Dim gvc As New GridViewColumn()&lt;br /&gt;  gvc.DisplayMemberBinding = New Binding(item.ColumnName)&lt;br /&gt;  gvc.Header = item.ColumnName&lt;br /&gt;  gvc.Width = [Double].NaN&lt;br /&gt;  gv.Columns.Add(gvc)&lt;br /&gt;Next&lt;/p&gt; &lt;p&gt;  ' Setup the GridView Columns&lt;br /&gt;lstData.View = gv&lt;br /&gt;' Display the Data&lt;br /&gt;lstData.DataContext = ds.Tables(0)&lt;br /&gt;End Sub&lt;br /&gt;Listing 1: Loop through the DataTable columns collection to create GridViewColumn objects&lt;/p&gt; &lt;p&gt;&lt;strong&gt;A Generic Method for Creating a GridView&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;Instead of having to write the code shown in Listing 1 for each ListView you wish to create, you can create a generic method that given any DataTable will return a GridView column collection. Listing 2 shows how you can simplify the code in Listing 1 by setting up a class called WPFListViewCommon and create a method called CreateGridViewColumns that returns your GridView.&lt;/div&gt; &lt;p&gt;C#&lt;br /&gt;private void DataTableSample()&lt;br /&gt;{&lt;br /&gt;// Read the data&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;ds.ReadXml(GetCurrentDirectory() + @"\Xml\Product.xml");&lt;/p&gt; &lt;p&gt;  // Setup the GridView Columns&lt;br /&gt;lstData.View =&lt;br /&gt;   WPFListViewCommon.CreateGridViewColumns(ds.Tables[0]);&lt;br /&gt;lstData.DataContext = ds.Tables[0];&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;VB.NET&lt;br /&gt;Private Sub DataTableSample()&lt;br /&gt;' Read the data&lt;br /&gt;Dim ds As New DataSet()&lt;br /&gt;ds.ReadXml(GetCurrentDirectory() &amp;amp; "\Xml\Product.xml")&lt;/p&gt; &lt;p&gt;  ' Setup the GridView Columns&lt;br /&gt;lstData.View = _&lt;br /&gt;    WPFListViewCommon.CreateGridViewColumns(ds.Tables(0))&lt;br /&gt;lstData.DataContext = ds.Tables(0)&lt;br /&gt;End Sub&lt;br /&gt;Listing 2: Call a generic method to create GridViewColumns.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The CreateGridViewColumns Method&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;The CreateGridViewColumns method will take a DataTable as a parameter and create a GridView object with a GridViewColumn object in its collection for each column in your DataTable.&lt;/div&gt; &lt;p&gt;C#&lt;br /&gt;public static GridView CreateGridViewColumns(DataTable dt)&lt;br /&gt;{&lt;br /&gt;// Create the GridView&lt;br /&gt;GridView gv = new GridView();&lt;br /&gt;gv.AllowsColumnReorder = true;&lt;/p&gt; &lt;p&gt;  // Create the GridView Columns&lt;br /&gt;foreach (DataColumn item in dt.Columns)&lt;br /&gt;{&lt;br /&gt;  GridViewColumn gvc = new GridViewColumn();&lt;br /&gt;  gvc.DisplayMemberBinding = new Binding(item.ColumnName);&lt;br /&gt;  gvc.Header = item.ColumnName;&lt;br /&gt;  gvc.Width = Double.NaN;&lt;br /&gt;  gv.Columns.Add(gvc);&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;  return gv;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;VB.NET&lt;br /&gt;Public Shared Function CreateGridViewColumns _&lt;br /&gt;(ByVal dt As DataTable) As GridView&lt;br /&gt;' Create the GridView&lt;br /&gt;Dim gv As New GridView()&lt;br /&gt;gv.AllowsColumnReorder = True&lt;/p&gt; &lt;p&gt;  ' Create the GridView Columns&lt;br /&gt;For Each item As DataColumn In dt.Columns&lt;br /&gt;  Dim gvc As New GridViewColumn()&lt;br /&gt;  gvc.DisplayMemberBinding = New Binding(item.ColumnName)&lt;br /&gt;  gvc.Header = item.ColumnName&lt;br /&gt;  gvc.Width = [Double].NaN&lt;br /&gt;  gv.Columns.Add(gvc)&lt;br /&gt;Next&lt;/p&gt; &lt;p&gt;  Return gv&lt;br /&gt;End Function&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;Listing 3: The CreateGridViewColumns method takes a DataTable and creates GridViewColumn objects in a GridView.&lt;/div&gt;&lt;div style="text-align: justify;"&gt; By separating this method out into a class you can call this method anytime you want to create a ListView with a collection of columns from a DataTable.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-5917581059503106001?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5917581059503106001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5917581059503106001'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/03/using-wpf-listview-as-datagrid.html' title='Using a WPF ListView as a DataGrid'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6637059918061511596</id><published>2010-02-20T01:29:00.000-08:00</published><updated>2010-02-20T01:38:41.710-08:00</updated><title type='text'>Highlight button during Asynchronous PostBack</title><content type='html'>If you don’t want to use &lt;span&gt;UpdateProgress&lt;/span&gt; during Asynchronous Postback from &lt;span&gt;UpdatePanel &lt;/span&gt;,There is an idea to highlight the button that fire the Asynchronous inside &lt;span&gt;UpdatePanel.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To start with this approach you must be familiar with &lt;span style="color: rgb(51, 102, 255);"&gt;PageRequestManager&lt;/span&gt; class and it's events  , PageRequestManager registered by &lt;span&gt;ScriptManager.&lt;/span&gt; With &lt;span&gt;PageRequestManager&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;you can manages &lt;span&gt;partial-page renderi&lt;/span&gt;&lt;span&gt;ng&lt;/span&gt; in the browser.&lt;br /&gt;On other hand you can’t access &lt;span&gt;PageRequestManager&lt;/span&gt; event’s directly, just you can access it through getInstance method.&lt;br /&gt;&lt;br /&gt;The most popular events, as well I use it in my example here are &lt;span style="font-weight: bold;"&gt;beginRequest &lt;/span&gt;&lt;span&gt;and &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;endRequest events.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;beginRequest:&lt;/span&gt;Raised before the processing of an asynchronous postback starts.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;endRequest:&lt;/span&gt; Raised after an asynchronous postback is finished and control has been returned to the browser.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Now lets take a look to the example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&gt;head runat="server"&gt;&lt;br /&gt; &gt;title&gt; check it &gt;/title&gt;&lt;br /&gt;&gt;/head&gt;&lt;br /&gt;&gt;body&gt;&lt;br /&gt; &gt;form id="form1" runat="server"&gt;&lt;br /&gt; &gt;div&gt;&lt;br /&gt;     &gt;asp:ScriptManager ID="sm1" runat="server" /&gt;&lt;br /&gt;     &gt;script language="javascript" type="text/javascript"&gt;&lt;br /&gt;         Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(update_begin);&lt;br /&gt;         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(update_end);&lt;br /&gt;         var btn = null;&lt;br /&gt;         var Counter = 0;&lt;br /&gt;         var timer;&lt;br /&gt;&lt;br /&gt;function MyTimer() {&lt;br /&gt;         Counter++;&lt;br /&gt;             if (Counter % 2 == 0)&lt;br /&gt;                 btn.style.background = "#dddddd";&lt;br /&gt;             else&lt;br /&gt;                 btn.style.background = "#eeeeee";&lt;br /&gt;             timer = window.setTimeout("MyTimer()", 500);&lt;br /&gt;         }&lt;br /&gt;      &lt;br /&gt;function ClearTimer() {&lt;br /&gt;             window.clearTimeout(timer);&lt;br /&gt;             Counter = -1;&lt;br /&gt;             btn.style.background = "#dddddd";&lt;br /&gt;         }&lt;br /&gt;      &lt;br /&gt;function update_begin(sender, args) {&lt;br /&gt;             btn = args.get_postBackElement();&lt;br /&gt;             MyTimer();&lt;br /&gt;         }&lt;br /&gt;      &lt;br /&gt;function update_end() {&lt;br /&gt;             ClearTimer();&lt;br /&gt;}&lt;br /&gt;&gt;/script&gt;&lt;br /&gt;&lt;br /&gt;     &gt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;&lt;br /&gt;         &gt;ContentTemplate&gt;&lt;br /&gt;             &gt;asp:Button ID="btnSubmit1" runat="server" Text="Submit 1" BackColor="#dddddd"&lt;br /&gt;OnClick="btnSubmit1_Click" /&gt;&lt;br /&gt;             &gt;asp:Button ID="btnSubmit2" runat="server" Text="Submit 2" BackColor="#dddddd"&lt;br /&gt;OnClick="btnSubmit2_Click" /&gt;&lt;br /&gt;             &gt;br /&gt;&lt;br /&gt;             &gt;asp:Label ID="lblMessage" runat="server" Text=""&gt;&lt;br /&gt;         &gt;/ContentTemplate&gt;&lt;br /&gt;     &gt;/asp:UpdatePanel&gt;&lt;br /&gt; &gt;/div&gt;&lt;br /&gt; &gt;/form&gt;&lt;br /&gt;&gt;/body&gt;&lt;br /&gt;&gt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In code behind :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;protected void btnSubmit1_Click(object sender, EventArgs e)&lt;br /&gt; {&lt;br /&gt;     System.Threading.Thread.Sleep(2400);&lt;br /&gt;     lblMessage.Text = "You Press button 1";&lt;br /&gt; }&lt;br /&gt; protected void btnSubmit2_Click(object sender, EventArgs e)&lt;br /&gt; {&lt;br /&gt;     System.Threading.Thread.Sleep(3000);&lt;br /&gt;     lblMessage.Text = "You Press button 2";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;In the previous example we catch which Element caused the Asynchronous &lt;span&gt;PostBack&lt;/span&gt; by &lt;span style="font-weight: bold;"&gt;args.get_postBackElement()&lt;/span&gt;, In this way you can get the Control ID throw &lt;span style="font-weight: bold;"&gt;args.get_postBackElement()&lt;/span&gt;.id. And you can catch if the control which cased the Asynchronous &lt;span&gt;PostBack&lt;/span&gt;  not a button, in case your UpdatePanel contain many controls which cause Asynchronous &lt;span&gt;PostBack.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the other hand you can use your own style to highlight your controls.&lt;br /&gt;&lt;br /&gt;The last note here that I add &lt;span style="font-weight: bold;"&gt;System.Threading.Thread.Sleep(3000)&lt;/span&gt;; to the Click handler, which artificially creates a three-second delay and then displays the button Highlighted.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6637059918061511596?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6637059918061511596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6637059918061511596'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/if-you-dont-want-to-use-updateprogress.html' title='Highlight button during Asynchronous PostBack'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-652685279922140842</id><published>2010-02-07T23:19:00.001-08:00</published><updated>2010-02-07T23:20:24.880-08:00</updated><title type='text'>ASP.NET SECURITY: AUTHENTICATION AND AUTHORIZATION</title><content type='html'>ASP.NET gives developers very flexible and powerful capabilities in to secure to make decisions considering user actions.To apply settings we want, we can edit web.config, machine.config, IIS.Besides this settings there are great classes and namespaces in .NET ( we will use generally system.web.security ).Let's start with &lt;authentication&gt; element in web.config. (Authentication is the process that determines the identity of a user, in other words asking user his/her credentials.Authorization,on the other hand, after validating credential, giving the user access to any specific part of the application) &lt;br /&gt; &lt;br /&gt;&gt;authentication mode="Forms"&gt; //possible values are "Windows|Forms|Passport|Name   &lt;br /&gt;&lt;br /&gt;&gt;/authentication&gt; &lt;br /&gt; 90% we use authentication mode "Forms" so no need to focus on other types.By using &gt;authorization&gt; we define accession rules for specific folders or pages or website as a whole.&lt;br /&gt; &lt;br /&gt;&gt;authorization&gt;&lt;br /&gt;&lt;br /&gt;      &gt;deny users="*"/&gt;&lt;br /&gt;&lt;br /&gt;      &gt;allow roles="administrator"/&gt;&lt;br /&gt;&lt;br /&gt;&gt;/authorization&gt; &lt;br /&gt;&lt;br /&gt;This setting first of all denies all users (*) then gives the access right to the role administrator.If we place this xml in web.config on the root of the application then it uses these settings for whole website.But in specific folders it is applied only to that folder. ie in our example, it seems that this code is for admin directory ( it gives access rights just for administrator(s).) We have deny and allow tags and users and roles attributes.For our need we can use them appropriate combination.And an example of how to use system.web.security and its basic functionalities:&lt;br /&gt;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;protected void LoginButton_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (Membership.ValidateUser(TextBox1.Text, TextBox2.Text))  //this method takes two arguments username,password&lt;br /&gt;{&lt;br /&gt;FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, true); //go to page which was intended &lt;br /&gt;//before redirected to loginpage           &lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;FormsAuthentication.RedirectToLoginPage();  //otherwise go to loginpage again&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-652685279922140842?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/652685279922140842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/652685279922140842'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/asp.html' title='ASP.NET SECURITY: AUTHENTICATION AND AUTHORIZATION'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-189877067779482378</id><published>2010-02-07T23:14:00.000-08:00</published><updated>2010-02-07T23:17:00.288-08:00</updated><title type='text'>ADO.NET HIERARCHY</title><content type='html'>Whether we use ADO.NET or not generally we don't know about hierarcy of ADO.NET namespaces and classes. Therefore, I want to write its general hierarcy:&lt;br /&gt;&lt;br /&gt;ADO.NET NAMESPACES&lt;br /&gt;&lt;br /&gt;    * System.Data&lt;br /&gt;    * System.Data.Common&lt;br /&gt;    * System.Data.SqlClient&lt;br /&gt;&lt;br /&gt;System.Data: The core of ADO.NET. Tables, Rows, Columns and DataSet  are all tools that are in System.Data. This namespace implements IDbCommand, IDbConnection, IDbDataAdapter interfaces.&lt;br /&gt;&lt;br /&gt;System.Data.Common: This namespace is generally for custom data providers because it includes base classes of all providers in ASP.NET. For example if you want to write your own SQL provider, then you should use System.Data.Common.&lt;br /&gt;&lt;br /&gt;System.Data.SqlClient: Data Provider for SQL. SqlCommand,SqlConnection etc. are in this class.&lt;br /&gt;&lt;br /&gt;Now let's group ADO.NET classes considering their base features.&lt;br /&gt;&lt;br /&gt;    *  Classes don't need live connection to database&lt;br /&gt;    *  Classes do need live connection to database&lt;br /&gt;    *  Base classes for Data Providers&lt;br /&gt;    *  and Data Providers&lt;br /&gt;&lt;br /&gt;Classes don't need live connection to database:  Their most important and basic future is to recreate tables (with its rows, columns, functional dependencies and all its futures) in memory and manipulate them. When needed they send this tables to client side. These classes includes DataSets, DataTables.&lt;br /&gt;&lt;br /&gt;Classes do need live connection to database:   Like DataReader class, gets the actual form of database and sends it to the client. If there is an update on the server side it should be resent. To do so, it requires live connection.&lt;br /&gt;&lt;br /&gt;Base classes for Data Providers : These classes are in System.Data.Common and are base classes for all Data Providers. (including our own custom providers)&lt;br /&gt;&lt;br /&gt;DataProvider classes: For each Data Provider, we have a unique DataProvider class. We do all operation related to a specific data source by its own DataProvider. Each and every Data Provider has its own DataConnection, Command, Adapter and Reader objects.&lt;br /&gt;&lt;br /&gt;Let's examine a portion of a data access layer class. (This is a general ADO.NET example. In subsequent entries, I'll give more specific examples)&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Data.SqlClient;           //This is for MSSQL operations. &lt;br /&gt;&lt;br /&gt;public static void Insert_Customers(Guid? userID, string name, string surname, string tel_no)&lt;br /&gt;{&lt;br /&gt;SqlConnection conn = null;  //for database connection&lt;br /&gt;SqlCommand cmd = null;   &lt;br /&gt;//  with this object we send necessary commands (sql queries)&lt;br /&gt;//  to database&lt;br /&gt;SqlTransaction trans = null;  //SqlTransaction is used for insert and delete&lt;br /&gt;//when there is an exception, we can undo our operations&lt;br /&gt;//with this object &lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ImaletConnectionString"].ConnectionString);&lt;br /&gt;conn.Open();&lt;br /&gt;trans = conn.BeginTransaction();&lt;br /&gt;cmd = new SqlCommand("Insert_Customer",conn);&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;cmd.Transaction = trans;&lt;br /&gt;cmd.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier); &lt;br /&gt;//add sql parameters with the same name in sql queries&lt;br /&gt;cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 20);  &lt;br /&gt;cmd.Parameters.Add("@Surname", SqlDbType.NVarChar, 20);&lt;br /&gt;cmd.Parameters.Add("@Tel_No", SqlDbType.NVarChar, 20);&lt;br /&gt;cmd.Parameters[1].Value = name;&lt;br /&gt;cmd.Parameters[2].Value = surname;&lt;br /&gt;cmd.Parameters[3].Value = tel_no;&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;trans.Commit();&lt;br /&gt;}&lt;br /&gt;catch (Exception pr)&lt;br /&gt;{&lt;br /&gt;if (trans != null)&lt;br /&gt;trans.Rollback();       &lt;br /&gt;//if there is an exception undo current operation&lt;br /&gt;throw new Exception();&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;if (conn != null)&lt;br /&gt;conn.Close();  &lt;br /&gt;// with Dispose() we prompt C# compiler to delete our objects&lt;br /&gt;cmd.Dispose();&lt;br /&gt;trans.Dispose();&lt;br /&gt;conn.Dispose();&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-189877067779482378?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/189877067779482378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/189877067779482378'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/adonet-hierarchy.html' title='ADO.NET HIERARCHY'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-8627738591285588884</id><published>2010-02-07T23:11:00.000-08:00</published><updated>2010-02-07T23:12:00.426-08:00</updated><title type='text'>NET IO - 1 ( Creating and Deleting Files and Directories and Listing subfiles and subdirectories )</title><content type='html'>There are advanced classes in .NET for IO processing. Even though we have some classes that allow us to carry out low level IO operations, we can usually do our work with several static methods. Now let's see how a directory and a file is created, deleted and how directory hierarchy in a disk volume or in a directory can be displayed in tree view. Although IO operations are same in all .NET projects, to make easier our article I use ASP.NET. Hence you can easily copy and paste code below in, for example, WPF. Classes, we will use, are: &lt;br /&gt;· DriveInfo&lt;br /&gt;· DirectoryInfo&lt;br /&gt;· FileInfo&lt;br /&gt;· Directory&lt;br /&gt;· File&lt;br /&gt;To create a directory or file &lt;br /&gt;Directory and File classes in System.IO namespace allow us to create and delete directories or files:&lt;br /&gt;&lt;br /&gt;Directory.Create(@"C:\exampleDirectory");&lt;br /&gt;Directory.Delete(@"C:\exampleDirectory");&lt;br /&gt;If we want to work on files and directories in current project folder,  &lt;br /&gt;Directory.Create(@"Server.MapPath("exampleDirectory"));  &lt;br /&gt;Directory.Delete(@"Server.MapPath("exampleDirectory"));  &lt;br /&gt;we can use. When operating on files, use File class: &lt;br /&gt;File.Create(@"C:\exampleFile.doc")&lt;br /&gt;File.Delete(@"C:\exampleFile.doc")&lt;br /&gt;or &lt;br /&gt;File.Create(@"Server.MapPath("exampleFile"));  &lt;br /&gt;File.Delete(@"Server.MapPath("exampleFile"));  &lt;br /&gt;Now let's work on displaying directory and file hierarchy in treeView like "windows explorer" style. We will use these classes:&lt;br /&gt;· System.IO.DriveInfo        //allows us to access the name, available space, total space etc. of a disk volume&lt;br /&gt;· System.IO.DirectoryInfo    //allows us to access the name, available space, total space etc. of directory&lt;br /&gt;Create a new site, add TreeView and wrote below code in Page_Load event: &lt;br /&gt;rotected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            System.IO.DriveInfo drive = new System.IO.DriveInfo(@"D:\"); &lt;br /&gt;            //work on local disk D&lt;br /&gt;            TreeNode node = new TreeNode(); &lt;br /&gt;            //we create TreeNode's dinamically&lt;br /&gt;&lt;br /&gt;            node.Value = drive.Name;  &lt;br /&gt;            TreeView1.Nodes.Add(node); &lt;br /&gt;            //add local disk D to main node&lt;br /&gt;&lt;br /&gt;            loadDirectories (node, drive.Name);//in this recursive method,&lt;br /&gt;            // we pass name and full address of the local disk &lt;br /&gt;            // as parameters            &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void loadDirectories(TreeNode parent, string path)&lt;br /&gt;    {&lt;br /&gt;        System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(path); &lt;br /&gt;        //now we don't work on drives but directories&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;           //with  GetDirectories(), we get all sub directories&lt;br /&gt;            foreach (System.IO.DirectoryInfo d in directory.GetDirectories()) &lt;br /&gt;            {&lt;br /&gt;                TreeNode node = new TreeNode(d.Name, d.FullName);                &lt;br /&gt;&lt;br /&gt;                parent.ChildNodes.Add(node);  &lt;br /&gt;&lt;br /&gt;                //call the same method (call "loadDirectories()" recursively )&lt;br /&gt;                loadDirectories(node, d.FullName);        &lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        catch (System.UnauthorizedAccessException e)&lt;br /&gt;        {&lt;br /&gt;            parent.Text += "(acces forbiddeni)";&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (System.IO.IOException e)&lt;br /&gt;        {&lt;br /&gt;            parent.Text += "(unknown error hata: " + e.Message + ")";&lt;br /&gt;        }   &lt;br /&gt;    }&lt;br /&gt;We displayed just content of volume D by writing ”System.IO.DriveInfo drive = new System.IO.DriveInfo(@"D:\");". If we wanted to display all files and directories in computer hard disk, we would write: &lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())  &lt;br /&gt;            //to work on all volumes&lt;br /&gt;            {&lt;br /&gt;                TreeNode node = new TreeNode();&lt;br /&gt;                node.Value = drive.Name;&lt;br /&gt;&lt;br /&gt;                if (drive.IsReady)&lt;br /&gt;                {&lt;br /&gt;                    node.Text = drive.Name;&lt;br /&gt;                    loadDirectories(node, drive.Name);&lt;br /&gt;                }                            &lt;br /&gt;&lt;br /&gt;                TreeView1.Nodes.Add(node);&lt;br /&gt;            } &lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;The code below takes several minutes. As you can estimate,  our recursive method "loadDirectories()" needs many IO operations. &lt;br /&gt;&lt;br /&gt;Now add a GridView to the project. We want to select a file from the TreeView we just created, and see alll subfiles and subdirectories with their name, space, last access time etc. Select SelectedNodeChanged event in "Properties Window" after clicking on TreeView and write the code below. &lt;br /&gt;protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        DirectoryInfo directory = new DirectoryInfo(TreeView1.SelectedNode.Value);&lt;br /&gt;&lt;br /&gt;        GridView1.DataSource = directory.GetFiles();&lt;br /&gt;        GridView1.DataBind();&lt;br /&gt;    }&lt;br /&gt;We learned how to create and delete files and directories and displaying all subdirectories and files in a disk, hierarchically in a TreeView.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-8627738591285588884?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8627738591285588884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8627738591285588884'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/net-io-1-creating-and-deleting-files.html' title='NET IO - 1 ( Creating and Deleting Files and Directories and Listing subfiles and subdirectories )'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-8013392164892033929</id><published>2010-02-07T22:36:00.000-08:00</published><updated>2010-02-07T22:39:16.172-08:00</updated><title type='text'>NEW FEATURES COME WITH ASP.NET 4.0</title><content type='html'>&lt;div class="entry-body"&gt;&lt;div&gt;&lt;div class="item-body"&gt;&lt;div&gt;&lt;div align="justify"&gt; Like ASP.NET 3.5, ASP.NET 4.0 comes with many new features. In Mix09 there were several sessions, I haven't yet written about, about new features ASP.NET will make available in version 4.0  We'll see them but to show you the path ASP.NET has pursuit, first, which improvements ASP.NET 3.5 made:&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Microsoft Entity Framework&lt;/li&gt;&lt;li&gt;ADO.NET Data Services&lt;/li&gt;&lt;li&gt;Dynamic Data&lt;/li&gt;&lt;li&gt;Microsoft Ajax Improvements&lt;/li&gt;&lt;/ol&gt;              --Browser History&lt;br /&gt;            --Script Combining&lt;br /&gt;&lt;br /&gt;Now new features of ASP.NET 4.0 in its all sub-framework:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Web Forms:&lt;/strong&gt;&lt;img style="float: right;" src="http://www.enestaylan.com/eng/image.axd?picture=2009%2f7%2fnetFramework.png" alt=".net hierachy" /&gt; &lt;ul&gt;&lt;li&gt; &lt;asp:formview&gt;.. tags. This is important because almost all developers use &lt;div&gt;..&lt;/div&gt; tags with .css files to control the layout of their pages. &lt;/asp:formview&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt; &lt;asp:listview&gt;.....&lt;/asp:listview&gt; Although clearly defining the layout sometimes can be very useful event crucial, in many situations developers use ListView for simple and easy situations and don't need it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt; ViewState is disabled default. ViewState is a major improvement of ASP.NET in web technologies. However many developers use it in situations that actually don't require ViewState and this results in waste of bandwidth (in big web pages, ViewState can be very big in terms of amount) So we have now for each ASP.NET control and also for Page ( Page is also a control ), "ViewStateMode=enabled,disabled,inherit" so we have more control over it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt; More control on Client IDs. ASP.NET has produce Client IDs for html output sent to the client considering layout and containers of the specific controls. This is useful because we can't control all the ids of all controls (especially for controls in data binding containers) However when we try to work on these controls, whose name is not known by us, with JavaScript problems start to arise. For example, when we refer to a control like "document.getElementByID(controlID)" we can't do anything. ASP.NET 4.0 solves this problem with (control.clientIdMode --&gt;&gt; legacy,static,predictable,inherit(default)).  ( Static means "use the id I gave. I am responsible all errors) (Predictable means "give an id considering containers but in a more clear way)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  Description and Keyword attributes for @Page for better search engine optimization.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  Enhancements in web standards (xhtml standarts,accessibility standarts section508,wcag,aria) and checking them in VS2010.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  A new ASP.NET control, QueryExtender, makes easy to query on entities that implements IQueriable&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  In ASP.NET 4.0 developers will be able to write their own custom cache providers.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  Session state compression (out-of-proc) with GZip.&lt;/li&gt;&lt;/ul&gt;&lt;strong&gt;ASP.NET Ajax 4.0&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  New data binding features on client side by using templates like ASP.NET databinding controls.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  jquery comes as part of the visual studio 2010&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  More enhanced Ajax Control Toolkit  (there is also client side libraries)&lt;/li&gt;&lt;/ul&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  Comes as a separate, stand-alone framework&lt;/li&gt;&lt;/ul&gt;&lt;strong&gt;ASP.NET Dynamic Data&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  New controls and more control for developer&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-8013392164892033929?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8013392164892033929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/8013392164892033929'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/new-features-come-with-aspnet-40.html' title='NEW FEATURES COME WITH ASP.NET 4.0'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-3284477168981854792</id><published>2010-02-07T22:15:00.000-08:00</published><updated>2010-02-07T22:25:33.792-08:00</updated><title type='text'>Taking Snapshots in ASP.NET</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 9"&gt;&lt;meta name="Originator" content="Microsoft Word 9"&gt;&lt;link rel="File-List" href="file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msoclip1/01/clip_filelist.xml"&gt;&lt;link rel="Edit-Time-Data" href="file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msoclip1/01/clip_editdata.mso"&gt;&lt;!--[if !mso]&gt; &lt;style&gt; v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} &lt;/style&gt; &lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:donotoptimizeforbrowser/&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} p 	{margin-right:0in; 	mso-margin-top-alt:auto; 	mso-margin-bottom-alt:auto; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} pre 	{margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; 	font-size:10.0pt; 	font-family:"Courier New"; 	mso-fareast-font-family:"Courier New"; 	mso-bidi-font-family:"Times New Roman";} span.keyword 	{mso-style-name:keyword;} span.string 	{mso-style-name:string;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */ @list l0 	{mso-list-id:212205818; 	mso-list-type:hybrid; 	mso-list-template-ids:691826664 1981437474 -709325020 -362264498 865352678 1649720988 210775336 -1668915254 1587966914 1022380318;} @list l1 	{mso-list-id:748694431; 	mso-list-type:hybrid; 	mso-list-template-ids:1018832172 1930078808 2078947468 -888392332 230357796 385381098 -404975800 1462401612 1231819166 1454917744;} @list l2 	{mso-list-id:1090346454; 	mso-list-type:hybrid; 	mso-list-template-ids:814382672 891315090 1987454776 -477737246 -2054125450 -1428102092 1026464982 744549180 94147418 1357314260;} @list l3 	{mso-list-id:1158880460; 	mso-list-type:hybrid; 	mso-list-template-ids:-304983708 -393563776 -27388114 -1041098082 1856692670 -1084749012 206325206 -1636772088 174236506 1554139000;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;Taking snapshots of web pages is used by many applications, for example Wordpress shows a small snapshot image of the page that a link directs to. In this post, I'll show how can we get snapshot image of a web page by using a small program, an .exe executable. Hence, it is the executable that creates the image actually and our asp.net page will make use of that .exe. First create a website, add a textbox and a button like below:&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_c2jrU6uj_ME/S2-tty_Q-tI/AAAAAAAAAKI/XI3747_fhrw/s1600-h/clip_image002.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 116px;" src="http://1.bp.blogspot.com/_c2jrU6uj_ME/S2-tty_Q-tI/AAAAAAAAAKI/XI3747_fhrw/s400/clip_image002.jpg" alt="" id="BLOGGER_PHOTO_ID_5435754277552323282" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:480.75pt;"&gt;  &lt;v:imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msoclip1/01/clip_image001.jpg" href="http://www.enestaylan.com/eng/image.axd?picture=2010%2f1%2fsnapshotPage.JPG"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Define a class level string &lt;span style="color:red;"&gt;imageName &lt;/span&gt;code button's click event:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span class="keyword"&gt;public&lt;/span&gt; partial &lt;span class="keyword"&gt;class&lt;/span&gt; _Default : System.Web.UI.Page   &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;{  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;string&lt;/span&gt; imageName = &lt;span class="string"&gt;"shot.png"&lt;/span&gt;;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;protected&lt;/span&gt; &lt;span class="keyword"&gt;void&lt;/span&gt; Button1_Click(&lt;span class="keyword"&gt;object&lt;/span&gt; sender, EventArgs e)  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    {  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        &lt;span class="keyword"&gt;string&lt;/span&gt; path = &lt;span class="keyword"&gt;this&lt;/span&gt;.GetImage(TextBox1.Text, imageName, Request.PhysicalApplicationPath , 200, 100);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Response.Redirect(&lt;span class="string"&gt;"~/Default2.aspx?path="&lt;/span&gt; + path);          &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    }  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;Click event above uses &lt;span style="color:red;"&gt;GetImage()&lt;/span&gt; method, we will talk about soon, and assigns the path of the image to the &lt;span style="color:red;"&gt;QueryString &lt;/span&gt;of &lt;span style="color:red;"&gt;Default2.aspx&lt;/span&gt;, the page responsible for displaying snapshot image. &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://www.enestaylan.com/eng/post/2010/01/05/Taking-Snapshot-in-ASPNET.aspx" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;"&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span class="keyword"&gt;public&lt;/span&gt; &lt;span class="keyword"&gt;string&lt;/span&gt; GetImage(&lt;span class="keyword"&gt;string&lt;/span&gt; url, &lt;span class="keyword"&gt;string&lt;/span&gt; name, &lt;span class="keyword"&gt;string&lt;/span&gt; rootDir, &lt;span class="keyword"&gt;int&lt;/span&gt; width, &lt;span class="keyword"&gt;int&lt;/span&gt; height)  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;{  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;string&lt;/span&gt; fName = rootDir + &lt;span class="string"&gt;"\\"&lt;/span&gt; + imageName;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    Shot(url, rootDir);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    System.Drawing.Image snapshotImage = System.Drawing.Image.FromFile(fName);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    fName = rootDir + &lt;span class="string"&gt;"\\" + "&lt;/span&gt;snapshots&lt;span class="string"&gt;" + "&lt;/span&gt;\\&lt;span class="string"&gt;" + name + "&lt;/span&gt;.png";  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;if&lt;/span&gt; (File.Exists(fName))  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        File.Delete(fName);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    snapshotImage .Save(fName, ImageFormat.Png);      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;return&lt;/span&gt; name;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;}  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;The&lt;span style="color:red;"&gt; GetImage()&lt;/span&gt; method, uses &lt;span style="color:red;"&gt;Shot() &lt;/span&gt;by assigning relative path of the image and root directory. After invoking Shot() method, it gets the image file that &lt;span style="color:red;"&gt;Shot()&lt;/span&gt; got and saved.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span class="keyword"&gt;private&lt;/span&gt; &lt;span class="keyword"&gt;void&lt;/span&gt; Shot(&lt;span class="keyword"&gt;string&lt;/span&gt; url, &lt;span class="keyword"&gt;string&lt;/span&gt; rootDir)  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;{  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;try&lt;/span&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    {            &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Process p = &lt;span class="keyword"&gt;new&lt;/span&gt; Process();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.StartInfo.FileName = rootDir + &lt;span class="string"&gt;"IECapt.exe"&lt;/span&gt;;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.StartInfo.Arguments = String.Format(&lt;span class="string"&gt;"\"{0}\" \"{1}\""&lt;/span&gt;, url, rootDir + &lt;span class="string"&gt;"\\"&lt;/span&gt; + imageName);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.StartInfo.UseShellExecute = &lt;span class="keyword"&gt;false&lt;/span&gt;;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.StartInfo.CreateNoWindow = &lt;span class="keyword"&gt;false&lt;/span&gt;;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.Start();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.WaitForExit();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        p.Dispose();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Label1.Text = &lt;span class="string"&gt;"Success :) !!!!!"&lt;/span&gt;;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    }  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;catch&lt;/span&gt; (Exception ex)  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    {  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Label1.Text = ex.ToString();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    }  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;}  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;This method defines a Process to start and execute a file. Then it sets up arguments (the sequence of them are same with the ones if you would use this .exe in command line). &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;If you want to add the feature of Wordpress (showing snapshots when hovering on links) you can implement the code above as a Web Service. Then using that service via JavaScript, or with JQuery library to make it more easy, you can get that functionality. &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;b&gt;&lt;span style="background: rgb(255, 255, 102) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;color:red;" &gt;Note:&lt;/span&gt;&lt;span style="background: rgb(255, 255, 102) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt; IECapt.exe can be downloaded from &lt;a href="http://iecapt.sourceforge.net/" target="_blank"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;span style="color:red;"&gt;Note:&lt;/span&gt; Because IECapt.exe takes snapshot of the whole page with very big resolution you should scale it in many scenarios.&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;Our simple Default2.aspx just has a Image control and two lines of code in &lt;span style="color:red;"&gt;Page_Load&lt;/span&gt; event handler to show the image: &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span class="keyword"&gt;protected&lt;/span&gt; &lt;span class="keyword"&gt;void&lt;/span&gt; Page_Load(&lt;span class="keyword"&gt;object&lt;/span&gt; sender, EventArgs e)  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;{  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    &lt;span class="keyword"&gt;if&lt;/span&gt; (!&lt;span class="keyword"&gt;string&lt;/span&gt;.IsNullOrEmpty(Request.QueryString[&lt;span class="string"&gt;"path"&lt;/span&gt;]))  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    {  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Image1.ImageUrl = &lt;span class="string"&gt;"~//"&lt;/span&gt; + Request.QueryString[&lt;span class="string"&gt;"path"&lt;/span&gt;].ToString();  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;        Response.Write(Image1.ImageUrl);  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;    }  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;}  &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;pre name="code"&gt;&lt;span style="display: none;"&gt;protected void Page_Load(object sender, EventArgs e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;&lt;span style=""&gt;    &lt;/span&gt;if (!string.IsNullOrEmpty(Request.QueryString["path"]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;&lt;span style=""&gt;        &lt;/span&gt;Image1.ImageUrl = "~//" + Request.QueryString["path"].ToString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;&lt;span style=""&gt;        &lt;/span&gt;Response.Write(Image1.ImageUrl);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="display: none;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-3284477168981854792?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3284477168981854792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3284477168981854792'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/02/taking-snapshorts-in-aspnet.html' title='Taking Snapshots in ASP.NET'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_c2jrU6uj_ME/S2-tty_Q-tI/AAAAAAAAAKI/XI3747_fhrw/s72-c/clip_image002.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-931794076695832193</id><published>2010-01-24T21:25:00.001-08:00</published><updated>2010-01-24T21:27:41.422-08:00</updated><title type='text'>The Most Important WCF Class</title><content type='html'>&lt;pre&gt;&lt;span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; line-height: 19px; white-space: normal; font-size: 13px;"&gt;Even fairly experienced WCF programmers may never have had to deal with this little gem, however, it is the single most important class in the WCF framework. Why is that? Because the message class provides the fundamental abstraction which represents all data sent or received from any WCF endpoint.&lt;/span&gt;&lt;/pre&gt; &lt;h1&gt;Key Parts&lt;/h1&gt; &lt;p&gt;There are four key parts to the message class:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;Version &lt;/strong&gt;- The version property contains information about the SOAP and Addressing versions used by the message. WCF fully supports use of non-SOAP messages for which this property is will be None to indicate the lack of any special formatting.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Properties &lt;/strong&gt;- Message properties contain processing information about the message which will not be written to the underlying transport stream as part of the message content. One example of what message properties can be used for is controlling things like HTTP verbs and status codes.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Headers &lt;/strong&gt;- A collection of message headers. A few common headers such as To and Action can be accessed via shortcut properties in the headers collection.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Body &lt;/strong&gt;- You can’t actually access the message body because the Message class abstraction is mean to be used as if the content of the Message was a stream.&lt;/li&gt;&lt;/ul&gt; &lt;h1&gt;It’s Abstract&lt;/h1&gt; &lt;p&gt;This will come as a surprise to many people, because the WCF framework does a very good job of hiding this fact, but the Message class itself is an abstract class. So put away any preconceived notions you might have had about how WCF at it’s core can only be used for web services and XML based communication. The fact is that you could create a message class backed directly by a raw binary array if you didn’t want any kind of performance hit for loading the data… as a matter of fact you probably wouldn’t want to even waste your time doing that, because WCF does exactly that when you are using many of the default settings! Actually… it does it even more efficiently than you would probably do it on your own by taking advantage of buffer managers to reduce the number of allocations that need to be made as messages are being created and disposed. So, despite the fact that the underlying abstraction is streaming, WCF actually buffers messages into a byte array by default to allow for higher performance.&lt;/p&gt; &lt;h1&gt;It’s Streaming&lt;/h1&gt; &lt;p&gt;Once you read the message, it cannot be read again. For this reason, all custom message classes must also provide a MessageBuffer implementation. I won’t talk much about the MessageBuffer class at this point, other than to say that it is also abstract and it is responsible for creating additional “copies” of the message. I say “copies” because the default implementations that are most commonly used by the standard bindings won’t actually “copy” anything. They just return another instance backed by the same internal byte array. This makes for ultra efficient message copying, but is only possible because of another trait of the message… The reason Message implementers must provide their own MessageBuffer implementations is so that the copy operation itself can be as optimized as possible.&lt;/p&gt; &lt;h1&gt;&lt;strong&gt;It’s Immutable&lt;/strong&gt;&lt;/h1&gt; &lt;p&gt;Well… sort of. The properties and headers of the message can be modified at will, making things like routing logic and header processing much easier to deal with, but the message body itself cannot be modified using the Message or MessageBuffer classes. For this reason, many hooks  in the WCF internals where a Message might need to by modified will pass the message as a ref parameter so it can be swapped for another message.&lt;/p&gt; &lt;h1&gt;It’s Not XML&lt;/h1&gt; &lt;p&gt;The last basic thing you need to know about the Message class which I already touched on, but should make clear again… the Message class does have to not represent XML data! This may seem like a strange statement if you’ve looked casually at the methods provided by the message class. However, this is only due to the unfortunate naming that the WCF team chose for XmlDictionaryReader and XmlDictionaryWriter, which have a lot of methods for reading and writing XML data, but fully support reading and writing raw binary content as well.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-931794076695832193?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/931794076695832193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/931794076695832193'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/most-important-wcf-class.html' title='The Most Important WCF Class'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6267833249047555495</id><published>2010-01-21T22:55:00.000-08:00</published><updated>2010-01-21T23:42:24.097-08:00</updated><title type='text'>ADO.NET</title><content type='html'>&lt;p&gt;                                     Most applications need data access at one point of time making it a crucial component                                     when working with applications. Data access is making the application interact with                                     a &lt;span style="text-decoration: underline;"&gt;Database&lt;/span&gt;, where all the data is stored. Different applications have different requirements                                     for database access. VB .NET uses &lt;span style="color:blue;"&gt;ADO .NET&lt;/span&gt; (Active X Data                                     Object) as it's data access and manipulation protocol which also enables us to work                                     with data on the . Let's take a look why ADO .NET came into picture replacing                                     ADO.                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;&lt;u&gt;Evolution of ADO.NET&lt;/u&gt;&lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The first data access model, &lt;span style="color:blue;"&gt;DAO&lt;/span&gt; (data access model) was                                     created for local databases with the built-in Jet engine which had performance and                                     functionality issues. Next came &lt;span style="color:blue;"&gt;RDO&lt;/span&gt; (Remote Data Object)                                     and &lt;span style="color:blue;"&gt;ADO&lt;/span&gt; (Active Data Object) which were designed for Client &lt;span style="text-decoration: underline;"&gt;Server&lt;/span&gt; architectures                                     but, soon ADO took over RDO. ADO                                     was a good architecture but as the language changes so is the technology. With ADO,                                     all the data is contained in a &lt;span style="color:blue;"&gt;recordset &lt;/span&gt;object which had                                     problems when implemented on the network and penetrating &lt;span style="text-decoration: underline;"&gt;firewall&lt;/span&gt;. ADO was a &lt;span style="color:blue;"&gt;connected&lt;/span&gt; data                                     access, which means that when a connection to the database is established the connection                                     remains open until the application is closed. Leaving the connection open for the                                     lifetime of the application raises concerns about database &lt;span style="text-decoration: underline;"&gt;security&lt;/span&gt; and network                                     traffic. Also, as databases are becoming increasingly important and as they are                                     serving more people, a connected data access model makes us think about its productivity.                                     For example, an application with connected data access may do well when connected                                     to two clients, the same may do poorly when connected to 10 and might be unusable                                     when connected to 100 or more. Also, open database connections use system resources                                     to a maximum extent making the system performance less effective.                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;Why ADO.NET?&lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     To cope up with some of the problems mentioned above, ADO .NET came into existence.                                     ADO .NET addresses the above mentioned problems by maintaining a &lt;span style="color:blue;"&gt;disconnected&lt;/span&gt; database                                     access model which means, when an application interacts with the database, the                                     connection is opened to serve the request of the application and is closed as soon                                     as the request is completed. Likewise, if a database is Updated, the connection is                                     opened long enough to complete the Update operation and is closed. By keeping connections                                     open for only a minimum period of time, ADO .NET conserves system resources and provides                                     maximum security for databases and also has less impact on system performance. Also,                                     ADO .NET when interacting with  the database uses  and converts all the                                     data into &lt;span style="text-decoration: underline;"&gt;XML XML Format &lt;/span&gt;for database related operations making them more efficient.                                 &lt;/p&gt;                                 &lt;p&gt;                                  &lt;br /&gt;                                  &lt;strong&gt;&lt;u&gt;The ADO.NET Data Architecture&lt;/u&gt;&lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     Data Access in ADO.NET relies on two components: &lt;span style="color:blue;"&gt;DataSet&lt;/span&gt; and &lt;span style="color:blue;"&gt;Data                                     Provider&lt;/span&gt;.                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;DataSet &lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The dataset is a &lt;span style="color:blue;"&gt;disconnected&lt;/span&gt;, &lt;span style="color:blue;"&gt;in-memory&lt;/span&gt; representation                                     of data. It can be considered as a &lt;span style="color:blue;"&gt;local copy&lt;/span&gt; of the                                     relevant portions of the database. The DataSet is persisted in memory and the data                                     in it can be manipulated and updated independent of the database. When the use of                                     this DataSet is finished, changes can be made back to the central database for updating.                                     The data in DataSet can be loaded from any valid data source like &lt;span style="text-decoration: underline;"&gt;Microsoft SQL Server&lt;/span&gt; database, an Oracle database or from a Microsoft Access database.                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;Data Provider&lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The Data Provider is responsible for &lt;span style="color:blue;"&gt;providing&lt;/span&gt; and &lt;span style="color:blue;"&gt;maintaining&lt;/span&gt; the                                     connection to the database. A DataProvider is a set of related components that work                                     together to provide data in an efficient and performance driven manner. The .NET Framework                                     currently comes with two DataProviders: the &lt;span style="color:blue;"&gt;SQL Data Provider&lt;/span&gt; which                                     is designed only to work with Microsoft's SQL &lt;span style="text-decoration: underline;"&gt;Server&lt;/span&gt; 7.0 or later and the &lt;span style="color:blue;"&gt;OleDb                                     DataProvider&lt;/span&gt; which allows us to connect to other types of databases like Access                                     and Oracle. Each DataProvider consists of the following component classes:                                 &lt;/p&gt;                                 &lt;p&gt;                                     The &lt;span style="color:blue;"&gt;Connection &lt;/span&gt;object which provides a connection to                                     the database&lt;br /&gt;                                  The &lt;span style="color:blue;"&gt;Command &lt;/span&gt;object which is used to execute a command&lt;br /&gt;                                  The &lt;span style="color:blue;"&gt;DataReader&lt;/span&gt; object which provides a forward-only, read                                     only, connected recordset&lt;br /&gt;                                  The &lt;span style="color:blue;"&gt;DataAdapter&lt;/span&gt; object which populates a disconnected DataSet                                     with data and performs update                                 &lt;/p&gt;                                 &lt;p&gt;                                  &lt;br /&gt;                                  &lt;u&gt;Data access with ADO.NET can be summarized as follows:&lt;/u&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     A connection object establishes the connection for the application with the database.                                     The command object provides direct execution of the command to the database. If the                                     command returns more than a single value, the command object returns a DataReader                                     to provide the data. Alternatively, the DataAdapter can be used to fill the Dataset                                     object. The database can be updated using the command object or the DataAdapter.                                  &lt;br /&gt;                               &lt;br /&gt;                                  &lt;img alt="ADO .NET Data Architecture" src="http://www.startvbdotnet.com/ado/images/adoarc.gif" /&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;&lt;u&gt;Component classes that make up the Data Providers&lt;/u&gt;&lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;The Connection Object &lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The Connection object creates the connection to the database. Microsoft Visual Studio                                     .NET provides two types of Connection classes: the &lt;span style="color:blue;"&gt;SqlConnection&lt;/span&gt; object,                                     which is designed specifically to connect to Microsoft SQL Server 7.0 or later, and                                     the &lt;span style="color:blue;"&gt;OleDbConnection&lt;/span&gt; object, which can provide connections                                     to a wide range of database types like Microsoft Access and Oracle. The Connection                                     object contains all of the information required to open a connection to the database.                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;The Command Object &lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The Command object is represented by two corresponding classes: &lt;span style="color:blue;"&gt;SqlCommand&lt;/span&gt; and &lt;span style="color:blue;"&gt;OleDbCommand&lt;/span&gt;.                                     Command objects are used to execute commands to a database across a data connection.                                     The Command objects can be used to execute stored procedures on the database, SQL                                     commands, or return complete tables directly. Command objects provide three methods                                     that are used to execute commands on the database:                                 &lt;/p&gt;                                 &lt;p&gt;                                     &lt;span style="color:blue;"&gt;ExecuteNonQuery&lt;/span&gt;: Executes commands that have no return values                                     such as INSERT, UPDATE or DELETE                                  &lt;br /&gt;                                  &lt;span style="color:blue;"&gt;ExecuteScalar&lt;/span&gt;: Returns a single value from a database query                                  &lt;br /&gt;                                  &lt;span style="color:blue;"&gt;ExecuteReader&lt;/span&gt;: Returns a result set by way of a DataReader                                     object                                 &lt;/p&gt;                                 &lt;p&gt;                                  &lt;br /&gt;                                  &lt;strong&gt;The DataReader Object &lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The DataReader object provides a &lt;span style="color:blue;"&gt;forward-only&lt;/span&gt;, &lt;span style="color:blue;"&gt;read-only&lt;/span&gt;, &lt;span style="color:blue;"&gt;connected                                     stream&lt;/span&gt; recordset from a database. Unlike other components of the Data Provider,                                     DataReader objects cannot be directly &lt;span style="color:blue;"&gt;instantiated&lt;/span&gt;. Rather,                                     the DataReader is returned as the result of the Command object's &lt;span style="color:blue;"&gt;ExecuteReader&lt;/span&gt; method. The SqlCommand.ExecuteReader method returns a SqlDataReader object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in terms of system performance but requires the exclusive use of an open Connection object for the lifetime of the DataReader. &lt;/p&gt;                                 &lt;p&gt;                                     &lt;strong&gt;The DataAdapter Object &lt;/strong&gt;                                 &lt;/p&gt;                                 &lt;p&gt;                                     The DataAdapter is the class at the core of ADO .NET's disconnected data access. It                                     is essentially the &lt;span style="color:blue;"&gt;middleman&lt;/span&gt; facilitating all communication                                     between the database and a DataSet. The DataAdapter is used either to fill a DataTable                                     or DataSet with data from the database with it's &lt;span style="color:blue;"&gt;Fill&lt;/span&gt; method.                                     After the memory-resident data has been manipulated, the DataAdapter can commit the                                     changes to the database by calling the Update method. The DataAdapter provides four                                     properties that represent database commands:                                 &lt;/p&gt;                                 &lt;p&gt;                                     SelectCommand&lt;br /&gt;                                  InsertCommand&lt;br /&gt;                                  DeleteCommand&lt;br /&gt;                                  UpdateCommand                                 &lt;/p&gt;                                 &lt;p&gt;                                     When the Update method is called, changes in the DataSet are copied back to the database                                     and the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.                                  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6267833249047555495?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6267833249047555495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6267833249047555495'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/adonet.html' title='ADO.NET'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-971925594350336807</id><published>2010-01-21T22:53:00.000-08:00</published><updated>2010-01-21T22:54:28.864-08:00</updated><title type='text'>.Net Framework</title><content type='html'>&lt;div class="post-body entry-content"&gt; &lt;p&gt; &lt;/p&gt;&lt;div&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;1. What  is .NET?&lt;/span&gt;&lt;br /&gt;.NET - is the Microsoft Web services strategy to connect  information, people, systems, and devices through software. Integrated across  the Microsoft platform, .NET technology provides the ability to quickly build,  deploy, manage, and use connected, security-enhanced solutions with Web  services. .NET-connected solutions enable businesses to integrate their systems  more rapidly and in a more agile manner and help them realize the promise of  information anytime, anywhere, on any device. &lt;a id="ctl00_ContentPlaceHolder1_hl1" href="http://www.microsoft.com/net/Basics.mspx" target="_blank"&gt;Reference&lt;/a&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;2. Which versions of  .NET have been released so far?&lt;/span&gt;  &lt;p class="a"&gt;The final version of the &lt;b&gt;.NET 1.0&lt;/b&gt; SDK &amp;amp; runtime were made  publically available on 15 - Jan -2002. At the same time, the final version of  Visual Studio.NET was made available to MSDN subscribers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;.NET  1.1&lt;/b&gt; was released in April 2003, with bugs fixed. &lt;b&gt;Visual Studio 2003&lt;/b&gt;  supports development of applications in version 1.1.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;.NET 2.0&lt;/b&gt; was  launched in October 2005 for MSDN subscribers, and officially released in Nov  2005.&lt;br /&gt;&lt;br /&gt;On - Jun - 2006, &lt;b&gt;.NET 3.0&lt;/b&gt; was launched. This version was  earlier called WinFX. &lt;b&gt;Visual Studio 2005&lt;/b&gt; supports development of .NET 2.0  and .NET 3.0 applications. .NET 3 is comprised of the  following:&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Windows Communication Foundation&lt;br /&gt;Windows Presentation  Foundation&lt;br /&gt;Windows Workflow Foundation&lt;br /&gt;Windows Cardspace&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;The  next version of Visual Studio, code named &lt;b&gt;Orcas, Beta 1&lt;/b&gt; has been released  as a Beta Version. The &lt;b&gt;.NET Framework 3.5 Beta&lt;/b&gt; is also available as a  download.&lt;/p&gt;&lt;br /&gt;&lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;3.  Which versions of .NET have been released so far?&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;The final version of the &lt;b&gt;.NET 1.0&lt;/b&gt; SDK &amp;amp; runtime were made  publically available on 15 - Jan -2002. At the same time, the final version of  Visual Studio.NET was made available to MSDN subscribers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;.NET  1.1&lt;/b&gt; was released in April 2003, with bugs fixed. &lt;b&gt;Visual Studio 2003&lt;/b&gt;  supports development of applications in version 1.1.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;.NET 2.0&lt;/b&gt; was  launched in October 2005 for MSDN subscribers, and officially released in Nov  2005.&lt;br /&gt;&lt;br /&gt;On - Jun - 2006, &lt;b&gt;.NET 3.0&lt;/b&gt; was launched. This version was  earlier called WinFX. &lt;b&gt;Visual Studio 2005&lt;/b&gt; supports development of .NET 2.0  and .NET 3.0 applications. .NET 3 is comprised of the  following:&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Windows Communication Foundation&lt;br /&gt;Windows Presentation  Foundation&lt;br /&gt;Windows Workflow Foundation&lt;br /&gt;Windows Cardspace&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;The  next version of Visual Studio, code named &lt;b&gt;Orcas, Beta 1&lt;/b&gt; has been released  as a Beta Version. The &lt;b&gt;.NET Framework 3.5 Beta&lt;/b&gt; is also available as a  download.&lt;/p&gt; &lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;4.  Which tools can be used for .NET Development?&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;The &lt;b&gt;.NET Framework SDK&lt;/b&gt; is free and includes command-line  compilers for C++, C#, and VB.NET and various other utilities to aid  development.&lt;br /&gt;&lt;br /&gt;SharpDevelop is a free IDE for C# and  VB.NET.&lt;br /&gt;&lt;br /&gt;Microsoft Visual Studio Express editions are cut-down versions of  Visual Studio, for hobbyist or novice developers and are available for FREE  Download at Microsoft site. Note that .NET 2.0 Framework gets downloaded along  with Visual Studio Express &amp;amp; All versions above Visual Studio Express. &lt;a id="ctl00_ContentPlaceHolder1_hl2" href="http://msdn.microsoft.com/vstudio/express" target="_blank"&gt;Download Visual  Studio Express&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There are different versions for C#, VB, web  development etc. Microsoft Visual Studio Standard 2005 is around $300, or $200  for the upgrade.&lt;br /&gt;&lt;br /&gt;Microsoft VIsual Studio Professional 2005 is around  $800, or $550 for the upgrade. At the top end of the price range are the  Microsoft Visual Studio Team Edition for Software Developers 2005 with MSDN  Premium and Team Suite editions. Visual Web Developer Express is available as a  free download.&lt;br /&gt;&lt;br /&gt;The next version of Visual Studio, code named Orcas, Beta  1 has been released as a Beta Version and is available for download. &lt;a id="ctl00_ContentPlaceHolder1_hl1" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D1336F3E-E677-426B-925C-C84A54654414&amp;amp;displaylang=en" target="_blank"&gt;Download Orcas&lt;/a&gt;&lt;/p&gt; &lt;p class="a"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="q" style="font-weight: bold; color: rgb(204, 102, 0);"&gt;5. Explain CLI, CIL,  CTS, Metadata, CLS, IL and VES in .NET&lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;CLI&lt;/b&gt; - Common Language Infrastructure. Microsoft has a piece of  shared source, its the public implementation of ECMA Common Language  Infrastructure. This shared code is code-named "Rotor". It has around 3 million  lines of code. Those who are interesed in development of a language that targets  the .NET Framework, may extensively make use of this CLI. The following topics  are covered in the &lt;b&gt;Shared Source CLI&lt;/b&gt; :&lt;br /&gt;&lt;br /&gt;* The CLI type system&lt;br /&gt;*  Component packing &amp;amp; assemblies&lt;br /&gt;* Type Loading &amp;amp; JIT Compilatino&lt;br /&gt;*  Managed code &amp;amp; Execution Engine (CLR)&lt;br /&gt;* Description of Garbage Collection  process &amp;amp; memory management&lt;br /&gt;* The Platform Adaptation Layer (PAL): a  portability layer for Win32®, Mac OS® X, and FreeBSD&lt;br /&gt;&lt;br /&gt;Its been written by  the Microsoft Team that has developed the .NET Framework.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; A  compiled managed assembly is comprised of IL, Metadata and  Manifest.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CIL&lt;/b&gt; Stands for Common Intermediate Language. Its  actually a low level human readable language implementation of CLI. All  .NET-aware languages compile the source oode to an intermediate language called  Common Intermediate Language using the language specific compiler. It is also  possible to build .NET assemblies direclty using CIL using the &lt;b&gt;ilasm.exe&lt;/b&gt;  compiler. This compiler is shipped along with the .NET Framework 2.0 SDK. CIL is  the only language that allows access to each aspect of the &lt;b&gt;CTS&lt;/b&gt;. CIL is  the definition of the fundamentals of the .NET framework.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CTS&lt;/b&gt; -  stands for Common Type Specification. It is at the core of .NET Framework's  cross-language integration, type safety, and high-performance code execution. It  defines a common set of types that can be used with many different language  syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define  any syntax it wishes, but if that language is built on the CLR, it will use at  least some of the types defined by the CTS.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Metadata&lt;/b&gt; - is code  that describes the compiled IL. A .NET language compiler will generate the  metadata and store this in the assembly containing the CIL. Metadata describes  all class members and classes that are defined in the assembly, and the classes  and class members that the current assembly will call from another assembly. The  metadata for a method contains the complete description of the method, including  the class (and the assembly that contains the class), the return type and all of  the method parameters. When the CLR executes CIL it will check to make sure that  the metadata of the called method is the same as the metadata that is stored in  the calling method. This ensures that a method can only be called with exactly  the correct number of parameters and exactly the correct parameter  types.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CLS&lt;/b&gt; - Common Language Specification. A type that is CLS  compliant, may be used across any .NET language. CLS is a set of language rules  that defines language standards for a .NET language and types declared in it.  While declaring a new type, if we make use of the &lt;b&gt;[CLSCompliant]&lt;/b&gt;  attribute, the type is forced to conform to the rules of CLS.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;IL&lt;/b&gt;  - Intermediate Language, is the compiled form of the .NET language source code.  When .NET source code is compiled by the language specific compiler (say we  compile C# code using csc.exe), it is compiled to a .NET binary, which is  platform independent, and is called Intermediate Language code. The .NET binary  also comprises of metadata.&lt;br /&gt;&lt;br /&gt;Its important to note here that &lt;b&gt;metadata  describes the IL&lt;/b&gt;, whereas &lt;b&gt;manifest&lt;/b&gt; describes the  assembly.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VES&lt;/b&gt; - Virtual Execution System. The Virtual Execution  System(VES) provides an environment for executing managed code. It provides  direct support for a set of built-in data types, defines a hypothetical machine  with an associated machine model and state, a set of control flow constructs,  and an exception handling model.To a large extent, the purpose of the VES is to  provide the support required to execute the Common Intermediate Language  instruction set. &lt;/p&gt; &lt;br /&gt;&lt;p class="q"&gt;&lt;span style="font-weight: bold;"&gt;6. What is CLR in .NET?&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;Common Language Runtime&lt;/b&gt; - It is the implementation of CLI. The  core runtime engine in the Microsoft .NET Framework for executing applications.  The common language runtime supplies managed code with services such as  cross-language integration, code access security, object lifetime management,  resouce management, type safety, pre-emptive threading, metadata services (type  reflection), and debugging and profiling support. The ASP.NET Framework and  Internet Explorer are examples of hosting CLR.&lt;br /&gt;&lt;br /&gt;The CLR is a  multi-language execution environment. There are currently over 15 compilers  being built by Microsoft and other companies that produce code that will execute  in the CLR.&lt;br /&gt;&lt;br /&gt;The CLR is described as the "execution engine" of .NET. It's  this CLR that manages the execution of programs. It provides the environment  within which the programs run. The software version of .NET is actually the CLR  version.&lt;br /&gt;&lt;br /&gt;When the .NET program is compiled, the output of the compiler is  not an executable file but a file that contains a special type of code called  the &lt;b&gt;Microsoft Intermediate Language (MSIL, now called CIL, Common  Intermediate Language)&lt;/b&gt;. This MSIL defines a set of portable instructions  that are independent of any specific CPU. It's the job of the CLR to translate  this Intermediate code into a executable code when the program is executed  making the program to run in any environment for which the CLR is implemented.  And that's how the .NET Framework achieves Portability. This MSIL is turned into  executable code using a JIT (Just In Time) complier. The process goes like this,  when .NET programs are executed, the CLR activates the JIT complier. The JIT  complier converts MSIL into native code on a demand basis as each part of the  program is needed. Thus the program executes as a native code even though it is  compiled into MSIL making the program to run as fast as it would if it is  compiled to native code but achieves the portability benefits of MSIL.&lt;/p&gt; &lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;7. What  is a Class Library in .NET?&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;Class library&lt;/b&gt; is the another major entity of the .NET  Framework. This library gives the program access to runtime environment. The  class library consists of lots of prewritten code that all the applications  created in .NET aware languages and Visual Studio .NET will use. The code for  all the elements like forms, controls and the rest in VB .NET applications  actually comes from the class library.&lt;br /&gt;&lt;br /&gt;Code in class libraries may be  shared &amp;amp; reused. One of the core . NET libraries is &lt;b&gt;mscorlib.dll&lt;/b&gt;.  .NET language compilers reference this library automatically as it contains core  types. A class library, contains types, that may be used by external  applications. A class library may be a DLL or an EXE. Note that the .NET class  libraries, even though have a same extension as the old COM Win32 binaries, yet  they are very different internally. &lt;/p&gt;&lt;br /&gt;&lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;8.  Explain Managed code, managed class and managed data in .NET&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;Managed Code&lt;/b&gt; - The .NET framework provides lots of core  runtime services to the programs that run within it. For example - security  &amp;amp; exception handling. Such a code has a minimum level of information. It has  metadata associated with it. Such a code is called Managed Code. VB.NET, C#,  JS.NET code is managed by default. In order to make C++ code managed, we make  use of managed extensions, which is nothing but a postfix _gc after the class  name.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Managed Data&lt;/b&gt; - Data that is allocated &amp;amp; freed by the  .NET runtime's Garbage collecter.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Managed Class&lt;/b&gt; - A class whose  objects are managed by the CLR's garbage collector. In VC++.NET, classes are not  managed. However, they can be managed using managed extentions. This is done  using an _gc postfix. A managed C++ class can inherit from VB.NET classes, C#  classes, JS.NET classes. A managed class can inherit from only one class. .NET  does'nt allow multiple inheritance in managed classes.&lt;/p&gt;&lt;br /&gt;&lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;9. What  is an assembly in .NET? What is ILDASM?&lt;/span&gt; &lt;/p&gt;&lt;b&gt;Assembly&lt;/b&gt; - An assembly  may be an exe, a dll, an application having an entry point, or a library. It may  consist of one or more files. It represents a group of resources, type  definitions, and implementation of these types. They may contain references to  other assemblies. These resources, types &amp;amp; references are compacted in a  block of data called manifest. The manifest is a part of the assembly, which  makes it self-describing. Assemblies also increase security of code in .NET. An  assembly maybe shared(public) or private. The assembly, overall comprises of 3  entities: &lt;b&gt;IL, Manifest, Metadata&lt;/b&gt;. Metadata describes IL, whereas Manifest  describes the assembly.&lt;br /&gt;&lt;br /&gt;An assembly may be created by building the  class(the .vb or .cs file), thereby producing its DLL.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ILDASM&lt;/b&gt; -  The contents of an assembly may be viewed using the ILDASM tool, that comes with  the .NET SDK or the Visual Studio.NET. The ildasm.exe tool may also be used in  the command line compiler.&lt;br /&gt;&lt;p class="a"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;10.  What is Reflection in .NET?&lt;/span&gt; &lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;Reflection&lt;/b&gt; - The process of getting the metadata from  modules/assemblies. When .NET code is compiled, metadata about the types defined  in the modules is produced. These modules are in turn packaged as assemblied.  The process of accessing this metadata in called Reflection.&lt;br /&gt;&lt;br /&gt;The  namespace System.Reflection contains classes that can be used for interrogating  the types for a module/assembly. We use reflection for examining data type sizes  for marshalling across process &amp;amp; machine boundaries.&lt;br /&gt;&lt;br /&gt;Reflection is  also used for:&lt;br /&gt;&lt;br /&gt;1) To dynamically invoke methods (using  System.Type.InvokeMember)&lt;br /&gt;2) To dynamically create types at runtime (using  System.Reflection.Emit.TypeBuilder).&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;11. What are the different  types of assemblies in .NET?&lt;/span&gt;  &lt;p class="a"&gt;An assembly may be &lt;b&gt;Public or Private&lt;/b&gt;. A public assembly is  also called a &lt;b&gt;Shared Assembly&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;A &lt;b&gt;Satellite Assembly&lt;/b&gt; - is an  assembly that contains only resources, and no code. The resources are location  specific. A satellite assembly is associated with a main assembly, the one that  actually contains the code.&lt;/p&gt; &lt;p class="q" style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;11a.  What is the difference between a Public Assembly and a Private Assembly?&lt;/span&gt;  &lt;/p&gt; &lt;p class="a"&gt;An assembly is the basic building block in .NET. It is the compiled  format of a class, that contains Metadata, Manisfest &amp;amp; Intermediate Language  code.&lt;br /&gt;&lt;br /&gt;An assembly may be either &lt;b&gt;Public&lt;/b&gt; or &lt;b&gt;Private&lt;/b&gt;. A public  assembly means the same as &lt;b&gt;Shared Assembly&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Private  Assembly&lt;/b&gt; - This type of assembly is used by a single application. It is  stored in the application's directory or the applications sub-directory. There  is no version constraint in a private assembly.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Shared Assembly or  Public Assembly&lt;/b&gt; - A shared assembly has version constraint. It is stored in  the Global Assembly Cache (GAC). GAC is a repository of shared assemblies  maintained by the .NET runtime. It is located at &lt;b&gt;C:\Windows\Assembly OR  C:\Winnt\Assembly&lt;/b&gt;. The shared assemblies may be used by many applications.  To make an assembly a shared assembly, it has to be &lt;b&gt;strongly named&lt;/b&gt;. In  order to share an assembly with many applications, it must have a strong  name.&lt;br /&gt;&lt;br /&gt;A &lt;b&gt;Strong Name&lt;/b&gt; assembly is an assembly that has its own  identity, through its version and uniqueness.&lt;br /&gt;&lt;br /&gt;In order to convert a  private assembly to a shared assembly, i.e. to create a strongly named assembly,  follow the steps below...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1)&lt;/b&gt; Create a strong key using the  &lt;b&gt;sn.exe&lt;/b&gt; tool. This is used to created a cryptographic key pair. The key  pair that is generated by the Strong Name tool can be kept in a file or we can  store it our your local machine's &lt;b&gt;Crytographic Service Provider (CSP)&lt;/b&gt;.  For this, goto the .NET command interpreter, and type the  following...&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="code"&gt;sn -k C:\samplekey.snk &lt;/p&gt; &lt;p class="a"&gt;This will create a strong key and save it to the location  C:\samplekey.snk &lt;b&gt;2)&lt;/b&gt; If the key is stored in a file, just like we have  done above, we use the attribute &lt;b&gt;AssemblyKeyFileAttribute&lt;/b&gt;. This belongs  to the namespace &lt;b&gt;System.Reflection.AssemblyKeyFileAttribute&lt;/b&gt;. If the key  was in the CSP, we would make use of  System.Reflection.AssemblyKeyNameAttribute.&lt;br /&gt;&lt;br /&gt;Go to the assemblyinfo.vb  file of your project. Open this file. Make the following changes in this  file...&lt;br /&gt;&lt;/p&gt; &lt;p class="code"&gt;&lt;assembly:&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;We may write this in our code as well, like  this...&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Imports System.Reflection&lt;br /&gt;&lt;assembly:&gt;&lt;br /&gt;Namespace  StrongName&lt;br /&gt;Public class Sample&lt;br /&gt;End Class&lt;br /&gt;End Namespace&lt;br /&gt;&lt;/assembly:&gt;&lt;/assembly:&gt;&lt;/p&gt; &lt;p class="a"&gt;&lt;b&gt;3)&lt;/b&gt; Build your project. Your assembly is now strongly named. &lt;br /&gt;Installing the Shared assembly in GAC...&lt;br /&gt;Go to .NET command interpreter,  use the tool gacutil.exe&lt;br /&gt;Type the following...&lt;br /&gt;&lt;b&gt;gacutil /i  sampleclass.dll &lt;/b&gt;&lt;br /&gt;To uninstall it, use... &lt;b&gt;gacutil /u&lt;/b&gt;  sampleclass.dll. Visual Studio.NET provides a GUI tool for viewing all shared  assemblies in the GAC. &lt;/p&gt;   &lt;/div&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-971925594350336807?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/971925594350336807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/971925594350336807'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/net-framework.html' title='.Net Framework'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-3162866713540281797</id><published>2010-01-21T00:44:00.000-08:00</published><updated>2010-01-21T01:11:03.268-08:00</updated><title type='text'>How To Set Elements Of An Array Of A Private Type Using Visual Studio Shadows</title><content type='html'>Visual Studio uses &lt;a href="http://msdn.microsoft.com/library/bb514191.aspx" target="_blank" title="Using Publicize to Create Private Accessors"&gt;Publicize&lt;/a&gt; to create accessors public for private members and types of a type.&lt;p&gt;&lt;/p&gt;  &lt;p&gt;But when you try to set elements of a private array of elements of a private type, things get complicated.&lt;/p&gt;  &lt;p&gt;Imagine this hypothetic class to test:&lt;/p&gt;  &lt;pre&gt;&lt;span style="color:blue;"&gt;public static class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;private static readonly &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass&lt;/span&gt;[] myArray = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass&lt;/span&gt;[10];&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public static bool &lt;/span&gt;IsEmpty()&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;foreach &lt;/span&gt;(&lt;span style="color:blue;"&gt;var &lt;/span&gt;item &lt;span style="color:blue;"&gt;in &lt;/span&gt;myArray)&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;if &lt;/span&gt;((item != &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (!&lt;span style="color:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(item.Field)))&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;return false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;return true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;private class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;public string &lt;/span&gt;Field;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;  &lt;p&gt;If I want to write a test for the case when the array has “non empty” entries, I need to setup the array first.&lt;/p&gt;  &lt;p&gt;Using the accessors generated by Visual Studio, I would write something like this:&lt;/p&gt;  &lt;pre&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestClass&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClassTest&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestMethod&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public void &lt;/span&gt;IsEmpty_NotEmpty_ReturnsFalse()&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;int &lt;/span&gt;i = 0; i &lt;&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.myArray[i] = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass &lt;/span&gt;&lt;br /&gt;{ Field = i.ToString() };&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;expected = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;actual;&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;actual = &lt;span style="color: rgb(43, 145, 175);"&gt;MyClass&lt;/span&gt;.IsEmpty();&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Assert&lt;/span&gt;.AreEqual(expected, actual);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://11011.net/software/vspaste" target="_blank"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But the test will fail because, although the elements of&lt;br /&gt;&lt;/p&gt;&lt;p&gt;the private array &lt;strong&gt;myArray&lt;/strong&gt; can be read as &lt;strong&gt;MyClass_Accessor.MyInnerClass&lt;/strong&gt; instances,&lt;br /&gt;&lt;/p&gt;&lt;p&gt;they can’t be written as such.&lt;/p&gt;  &lt;p&gt;To do so, the test would have to be written like this:&lt;/p&gt;  &lt;pre&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestClass&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClassTest&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestMethod&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public void &lt;/span&gt;IsEmpty_NotEmpty_ReturnsFalse()&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;int &lt;/span&gt;i = 0; i &lt;&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.ShadowedType.SetStaticArrayElement&lt;br /&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myArray"&lt;/span&gt;, &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass &lt;/span&gt;{ Field = i.ToString() }.Target, i);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;expected = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;actual;&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;actual = &lt;span style="color: rgb(43, 145, 175);"&gt;MyClass&lt;/span&gt;.IsEmpty();&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Assert&lt;/span&gt;.AreEqual(expected, actual);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;  &lt;p&gt;But, this way, we loose all the strong typing of the accessors because we need to&lt;br /&gt;&lt;/p&gt;&lt;p&gt;write the name of the array field.&lt;/p&gt;  &lt;p&gt;Because the accessor for the field is a property, we could write a set of&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/library/bb383977.aspx" target="_blank" title="Extension Methods (C# Programming Guide)"&gt;extension methods&lt;/a&gt; that take care of getting the field name for us. Something&lt;br /&gt;&lt;/p&gt;&lt;p&gt;like this:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://11011.net/software/vspaste" target="_blank"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;pre&gt;&lt;span style="color:blue;"&gt;public static class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PrivateypeExtensions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public static void &lt;/span&gt;SetStaticArrayElement&lt;t&gt;(&lt;span style="color:blue;"&gt;this &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PrivateType &lt;/span&gt;self,&lt;br /&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Expression&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;&lt;t[]&gt;&gt; expression, T value, &lt;span style="color:blue;"&gt;params int&lt;/span&gt;[] indices)&lt;/t[]&gt;&lt;/t&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;object &lt;/span&gt;elementValue = (value &lt;span style="color:blue;"&gt;is &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BaseShadow&lt;/span&gt;) ? (value &lt;span style="color:blue;"&gt;as &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BaseShadow&lt;/span&gt;).Target : value;&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;self.SetStaticArrayElement(&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;((&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt;)((&lt;span style="color: rgb(43, 145, 175);"&gt;MemberExpression&lt;/span&gt;)(expression.Body)).Member).Name,&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;elementValue,&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;indices);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public static void &lt;/span&gt;SetStaticArrayElement&lt;t&gt;(&lt;span style="color:blue;"&gt;this &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PrivateType &lt;/span&gt;self, &lt;span style="color: rgb(43, 145, 175);"&gt;Expression&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Func&lt;/span&gt;&lt;t[]&gt;&gt;&lt;br /&gt; expression, &lt;span style="color: rgb(43, 145, 175);"&gt;BindingFlags &lt;/span&gt;invokeAttr, T value, &lt;span style="color:blue;"&gt;params int&lt;/span&gt;[] indices)&lt;/t[]&gt;&lt;/t&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;object &lt;/span&gt;elementValue = (value &lt;span style="color:blue;"&gt;is &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BaseShadow&lt;/span&gt;) ? (value &lt;span style="color:blue;"&gt;as &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;BaseShadow&lt;/span&gt;).Target : value;&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;self.SetStaticArrayElement(&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;((&lt;span style="color: rgb(43, 145, 175);"&gt;PropertyInfo&lt;/span&gt;)((&lt;span style="color: rgb(43, 145, 175);"&gt;MemberExpression&lt;/span&gt;)(expression.Body)).Member).Name,&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;invokeAttr,&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;elementValue,&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;indices);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://11011.net/software/vspaste" target="_blank"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, we can write the test like this:&lt;/p&gt;  &lt;pre&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestClass&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:blue;"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClassTest&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;TestMethod&lt;/span&gt;()]&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;public void &lt;/span&gt;IsEmpty_NotEmpty_ReturnsFalse()&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;for &lt;/span&gt;(&lt;span style="color:blue;"&gt;int &lt;/span&gt;i = 0; i &lt;&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.ShadowedType.SetStaticArrayElement(() =&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;&lt;br /&gt;MyClass_Accessor&lt;/span&gt;.myArray, &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyClass_Accessor&lt;/span&gt;.&lt;span style="color: rgb(43, 145, 175);"&gt;MyInnerClass &lt;/span&gt;{ Field = i.ToString() }, i);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;expected = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;bool &lt;/span&gt;actual;&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;actual = &lt;span style="color: rgb(43, 145, 175);"&gt;MyClass&lt;/span&gt;.IsEmpty();&lt;/pre&gt;&lt;pre&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Assert&lt;/span&gt;.AreEqual(expected, actual);&lt;/pre&gt;&lt;pre&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://11011.net/software/vspaste" target="_blank"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It’s not the same as the first form, but it’s strongly typed and we’ll get a compiler&lt;br /&gt;&lt;/p&gt;&lt;p&gt;error instead of a test run error if we change the name of the &lt;strong&gt;myArray &lt;/strong&gt;field.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;/pre&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-3162866713540281797?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3162866713540281797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3162866713540281797'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/how-to-set-elements-of-array-of-private.html' title='How To Set Elements Of An Array Of A Private Type Using Visual Studio Shadows'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-5602621393383995880</id><published>2010-01-20T01:55:00.000-08:00</published><updated>2010-01-20T01:57:02.247-08:00</updated><title type='text'>How to Create a Web Server Farm Cache</title><content type='html'>&lt;span id="konasapn0"&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Introduction&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Dynamic database-driven web sites are required if your site has large quantities of data to upload, manage, and serve back to your customers. However, IT departments typically say this creates too big a load for the database -- hence many people keep the files on the hard drive along with their script pages.  Not only does this not scale well when you expand from one web server to a web farm, it is hard to back-up, and the file system makes for a poor database -- lacking the transactional qualities of a database. &lt;/p&gt; &lt;p&gt; You can keep your files and images in the database if you take advantage of client-side caching and implement a web server file cache.  The benefits include: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;All your content in one place: textual, images, and relationships are in the database.&lt;/li&gt;&lt;li&gt;The ability to deploy the files to multiple web servers, without additional replication work.&lt;/li&gt;&lt;li&gt;The ability to backup all the content in a single database backup.&lt;/li&gt;&lt;li&gt;Minimum database reads for files, on low-write / high-read systems.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt; This article will show a simple way to deploy caching so that you can keep all your content in the database efficiently. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Associated Article&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; This article is provided in conjunction with another article about streaming uploaded files. The caching article's portion of this web site is in the &lt;em&gt;Cache.aspx&lt;/em&gt; file. The code for the upload portion of that web site and the associated file is called &lt;em&gt;UploadBlob.aspx&lt;/em&gt;. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Requirements&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; You need an IIS web server and a SQL server. The SQL tables, and stored procedures are provided in the &lt;em&gt;Upload.sql&lt;/em&gt; file. You will also need files to upload. The &lt;em&gt;/images&lt;/em&gt; directory of the associated web site has three images that you can use. A small view of each of the three images is below. &lt;/p&gt; &lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071012_01.gif" border="0" /&gt; &lt;/p&gt; &lt;p&gt; &lt;span style="font-weight: bold;"&gt;The SQL statement for creating the table is: &lt;/span&gt;&lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; CREATE TABLE [dbo].[UploadBytesOfBlob](&lt;br /&gt;    [FileGuid] [uniqueidentifier] NOT NULL,&lt;br /&gt;    [Name] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt;    [Content] [varbinary](max) NULL,&lt;br /&gt;    [ContentType] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt;    [Size] [numeric](18, 0) NULL,&lt;br /&gt;    [NumberOfChunks] [numeric](18, 0) NULL,&lt;br /&gt;    [FirstModifiedDate] [datetime] NULL,&lt;br /&gt;    [LastModifiedDate] [datetime] NULL,&lt;br /&gt;  CONSTRAINT [PK_UploadBytesOfBlob] PRIMARY KEY CLUSTERED&lt;br /&gt;(&lt;br /&gt;    [FileGuid] ASC&lt;br /&gt;)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]&lt;br /&gt;) ON [PRIMARY] &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The primary key for the table in the sql database is called &lt;em&gt;FileGuid&lt;/em&gt; and is of type &lt;em&gt;UniqueIdentifier&lt;/em&gt;. This is a Guid in terms of asp.net. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Compile and Run the Site&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;/span&gt;&lt;/p&gt; Download, compile, and run the site. Make sure to create the SQL table and stored procedures using the &lt;em&gt;Upload.sql&lt;/em&gt; file. You will be presented with the &lt;em&gt;Default.aspx&lt;/em&gt; file which has a link to the &lt;em&gt;UploadBlob.aspx&lt;/em&gt; page. Upload the &lt;em&gt;ascent.jpg&lt;/em&gt; file found in the /images directory. After the upload, you will be redirected to the &lt;em&gt;default.aspx&lt;/em&gt; and a GridView will show the image information. Do not click on either link just yet. Open a windows explorer and check that the file guid listed in the &lt;em&gt;default.aspx&lt;/em&gt; is not found in the &lt;em&gt;/CacheFolder&lt;/em&gt; of the web site. The folder should be empty. When the image is requested, the folder will have a file name &lt;em&gt;guid.dat&lt;/em&gt; where the actual database guid is the prefix of the filename. &lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;How the Cache System Works&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; For the rest of this article we will use the following web site idea. Assume we have an editor who uploads images as part of his work. The image is large and must eventually be loaded onto 12 web servers. The image may change from time to time so that the relevance of the image is current. When the image does change, it is important that the latest version of the image is used and not the image from the client-side cache or the web-server cache. &lt;/p&gt; &lt;p&gt; A customer of the web site then requests the page which includes the image. What happens? For the purposes of explaining the system, there will be several requests. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The First Request&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; On the very first request, the image is in the database but not in any cache. This system checks the client-side cache for the image including the relevant date of the image using the &lt;em&gt;If-Modified-Since&lt;/em&gt; request header. After the file is not found there, since it is the first request, the system checks the web server file cache including the relevant date of the image. The file is not found there, so the last step is to grab the image from the database. Since the web server is grabbing the file, the file is placed in the web's cache folder (our own system, not the IIS cache), and returned to the client. As part of the brower's work to handle the image coming down, it is placed in the client-side cache. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Second Request&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The customer comes back a second time to request the file while the file on the client-side cache is still the most current version. The cache system responds with a 304 and the client's system fetches the image locally. This has saved a trip to the database and it has also saved a trip to the web server's file system. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Content has Changed&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Imagine the editor has now uploaded a new version of the image into the database. All twelve web servers need to be updated with this new version. Instead of uploading the file to all twelve servers at the time of the change, the change is made to each web server as the image is requested. This means that the work of moving the file from the database to the web server is only done when necessary and is based on a client-request. This saves the IT department from having to deal with replication of the content across the web servers. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Third Request&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; On the next request, the file in the client's local cache is no longer current. The cache system checks the web server cache to see if that version is the most current. If the web server cache folder does have the most current, then that version is returned to the client. If that web server cache folder version is not the most current, the current image is fetched from the database, reloaded into the web server cache by writing the database content to a file, then returned to the client and placed in the client cache. &lt;/p&gt; &lt;p&gt; The URL for the system looks like cache.aspx?FileGuid=XYZ... The FileGuid is used instead of a name or incremental number for the content so that the database can grow to a large size while still managing the content. &lt;/p&gt; &lt;p&gt; The image URL on the page then looks like &lt;img src="cache.aspx?FileGuid=xyz..." /&gt;. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Sample Web Site&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The sample web site has three main files: &lt;em&gt;default.aspx&lt;/em&gt;, &lt;em&gt;cache.aspx&lt;/em&gt;, and &lt;em&gt;uploadblob.aspx&lt;/em&gt;. Download, compile and run the web site. Make sure to create the SQL table and stored procedures using the &lt;em&gt;Upload.sql&lt;/em&gt; file. Put a break point at the top of the &lt;em&gt;Page_Load&lt;/em&gt; method of the &lt;em&gt;cache.aspx.cs&lt;/em&gt; file. This is the area of code this article focuses on. &lt;/p&gt; &lt;p&gt; The first time you load the file, nothing will appear except a link to the upload page on the &lt;em&gt;default.aspx&lt;/em&gt;. As you upload images, this page will show a GridView listing those images. &lt;/p&gt; &lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071012_02.gif" border="0" /&gt; &lt;/p&gt; &lt;p&gt; Click on the Upload File link, and you will go to the upload page. Once you upload the ascent.jpg image, you will be redirected to the default.aspx file which will now show a GridView with a row for the ascent.jpg file: &lt;/p&gt; &lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071012_03.gif" border="0" /&gt; &lt;/p&gt; &lt;p&gt; Set a break point in the cache.aspx at the top of the Page_Load function. Now click on the link in the FileGuid column. The breakpoint should activate in Visual Studio. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;How the Code Works&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The FileGuid of each row is used in the URL to the cache.aspx file. The URL looks like cache.aspx?FileGuid=91d... The FileGuid is not only the primary key for the database but is also the name of the file in the cache folder.  &lt;/p&gt; &lt;p&gt; &lt;span style="font-weight: bold;"&gt;The code from cache.aspx for reading the FileGuid from the URL is: &lt;/span&gt;&lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     // DFB: fileGuid is required&lt;br /&gt;    if (Request["FileGuid"] == String.Empty)&lt;br /&gt;        throw (new Exception("FileGuid missing"));&lt;br /&gt;&lt;br /&gt;    // DFB: Capture fileGuid&lt;br /&gt;    Guid fileguid = new Guid(Request["FileGuid"]);&lt;br /&gt;&lt;br /&gt;    // DFB: fileGuid is required&lt;br /&gt;    if (fileguid == Guid.Empty)&lt;br /&gt;        throw (new Exception("FileGuid missing")); &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Notice that the FileGuid value from the Request is cast to a Guid datatype in aspx. This allows you to deal with the Guid object more easily and convert to the appropriate SQL data type when you need to. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Fetch From the Client Cache&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The client's browser cache is checked by comparing the &lt;em&gt;If-Modified-Since&lt;/em&gt; request header against the &lt;em&gt;LastModifiedDate&lt;/em&gt; from the database. If the client's browser cache has the most recent copy, a respond code of 304 is returned. &lt;/p&gt; &lt;p&gt; The code from cache.aspx for checking the client's cache &lt;em&gt;If-Modified-Since&lt;/em&gt; request header is: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     // DFB: connect to database&lt;br /&gt;    using (SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["Test"].ConnectionString))&lt;br /&gt;    {&lt;br /&gt;        sqlConnection.Open();&lt;br /&gt;&lt;br /&gt;        // DFB: Get LastModifiedDate value only. We only fetch more from this row as needed.&lt;br /&gt;        using (sqlCommand = new SqlCommand("select LastModifiedDate from SingleDataStore where FileGuid='" + fileguid.ToString() + "'", sqlConnection))&lt;br /&gt;        {&lt;br /&gt;            lastModifiedDate = DateTime.Parse(sqlCommand.ExecuteScalar().ToString());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // DFB: Get Client-side Browser Cache's If-Modified-Since Date&lt;br /&gt;        if(!String.IsNullOrEmpty(Request.Headers["If-Modified-Since"]))&lt;br /&gt;        {&lt;br /&gt;            ifModifiedSince = DateTime.Parse(Request.Headers["If-Modified-Since"], System.Globalization.CultureInfo.InvariantCulture);&lt;br /&gt;&lt;br /&gt;            // DFB: If the client-side browser cache has the most current version,&lt;br /&gt;            // then return 304 and let the client fetch from its own cache&lt;br /&gt;            if (lastModifiedDate &lt;= ifModifiedSince)&lt;br /&gt;            {&lt;br /&gt;                Response.StatusCode = 304;&lt;br /&gt;                Response.StatusDescription = "Not Modified";&lt;br /&gt;                Response.End();&lt;br /&gt;                return;&lt;br /&gt;            }&lt;br /&gt;        } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; From this point on in the code, the content will either come from the local web server's cache or the database. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Web Server's File System Cache&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In order to reduce reads from the database and propagate the content to all web servers in the farm, the cache.aspx file will store a copy on the local file system of each web server in the farm as the content is requested. &lt;/p&gt; &lt;p&gt; The first time a request for the data is made, the data is served from the database and a file is created on the local web server. Each subsequent request is served from the local web server instead of making the unnecessary request for the content from the database if the LastModifiedDate value in the database hasn't changed. &lt;/p&gt; &lt;p&gt; The location of the cache folder is in the web.config. You will want to put the folder at the root of the website. Make sure the IUSR_&lt;em&gt;servername&lt;/em&gt;, IWAM_&lt;em&gt;servername&lt;/em&gt;, and the ASPNET local accounts have full permission to the cache folder. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     // DFB: Build up cache path with file name where file name is guid.dat&lt;br /&gt;    // and the guid is the primary key of the table&lt;br /&gt;    cachePath = String.Format("{0}{1}.dat", ConfigurationManager.AppSettings["CacheFolder"], fileguid.ToString()); &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The file name will be &lt;em&gt;FileGuid.dat&lt;/em&gt;. The file isn't given an extension associated with the type of content because we do not need to associate it to a type of content until it is requested. It is faster to read the database content type (mime type) than to look up the corresponding file extension in the registry and then determine its content type. &lt;/p&gt; &lt;p&gt; When we set the file's last modified date, the date will be the LastModifiedDate found in the database.  This allows the code to determine if the file in the cache is out of sync with the database in future requests for the file. &lt;/p&gt; &lt;p&gt; If the directory is not found, it will be created. If the file is found in the directory, the date of the file is compared to the known LastModifiedDate returned from the database in the above code used for checking the client's cache. If the file is not found in the cache folder, the dirty flag is set to true. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     // DFB: if the file system cache folder doesn't exist, create it&lt;br /&gt;    if (!Directory.Exists(ConfigurationManager.AppSettings["CacheFolder"]))&lt;br /&gt;    {&lt;br /&gt;        Directory.CreateDirectory(ConfigurationManager.AppSettings["CacheFolder"]);&lt;br /&gt;        dirty = true;&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;        // DFB: Check to see if the file is in the cache&lt;br /&gt;        if (File.Exists(cachePath))&lt;br /&gt;        {&lt;br /&gt;            // DFB: Check the last write time of the file&lt;br /&gt;            FileInfo fileInfo = new FileInfo(cachePath);&lt;br /&gt;&lt;br /&gt;            // DFB: If times are different, mark the flag&lt;br /&gt;            // DFB: marking dirty mean to go get new data out of database&lt;br /&gt;            lastWriteTime = fileInfo.LastWriteTime;&lt;br /&gt;            dirty = (lastWriteTime != lastModifiedDate);&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            // DFB: file is not found in cache&lt;br /&gt;            dirty = true;&lt;br /&gt;        }&lt;br /&gt;    } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The dirty flag indicates that the content does need to be fetched from the database and written to the cache folder. It is important to understand that the content is read back from the database one chunk at a time inside a WHILE look. This allows for only the chunk size of the entire file to be in memory at a time. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;         if (dirty)&lt;br /&gt;        {&lt;br /&gt;            // DFB: Cached File Doesn't Exist or has old data so get data.&lt;br /&gt;&lt;br /&gt;            // DFB:Write Database Content to file&lt;br /&gt;            using (FileStream fileStream = File.Create(cachePath))&lt;br /&gt;            {&lt;br /&gt;                using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))&lt;br /&gt;                {&lt;br /&gt;                    Int64 sqlRead = 0;&lt;br /&gt;                    Int64 index = 0;&lt;br /&gt;                    Byte[] buffer = new Byte[1024];&lt;br /&gt;&lt;br /&gt;                    using (sqlCommand = new SqlCommand("select Content from UploadBytesOfBlob where FileGuid='" + fileguid.ToString() + "'", sqlConnection))&lt;br /&gt;                    {&lt;br /&gt;                        using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))&lt;br /&gt;                        {&lt;br /&gt;                            if (!sqlDataReader.HasRows)&lt;br /&gt;                                throw (new Exception("Invalid Id"));&lt;br /&gt;&lt;br /&gt;                            sqlDataReader.Read();&lt;br /&gt;&lt;br /&gt;                            while ((sqlRead = sqlDataReader.GetBytes(0, index, buffer, 0, buffer.Length)) != 0)&lt;br /&gt;                            {&lt;br /&gt;                                // WWB: Cast Is Fine Size Buffer &lt; int.MaxValue&lt;br /&gt;                                binaryWriter.Write(buffer, 0, (int)sqlRead);&lt;br /&gt;                                index += sqlRead;&lt;br /&gt;                            }&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // DFB: Time Stamp The Last Modified Time With&lt;br /&gt;            // The Last Modified Time of the FileStore Object&lt;br /&gt;            // So that we can track changes&lt;br /&gt;            FileInfo fileInfo = new FileInfo(cachePath);&lt;br /&gt;            fileInfo.LastWriteTime = lastModifiedDate;&lt;br /&gt;        } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Once the file is in the cache folder, you need to construct the response to the client. This includes cache values, the content type, and the content. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;         // DFB: Setup To Successfully Cache The Page On the Client&lt;br /&gt;        Response.Cache.SetLastModified((lastModifiedDate).ToUniversalTime());&lt;br /&gt;        Response.Cache.SetCacheability(HttpCacheability.Public);&lt;br /&gt;&lt;br /&gt;        // DFB: ETag determines if data has changed on server&lt;br /&gt;        // DFB: ETag can be server/programmer specific be should&lt;br /&gt;        // be generated at the server to indicate data uniqueness&lt;br /&gt;        // DFB: For this program, I'll has the row's id with the row's&lt;br /&gt;        // last modified date&lt;br /&gt;        Response.Cache.SetETag(Hash(Request["FileGuid"].ToString() + lastModifiedDate));&lt;br /&gt;&lt;br /&gt;        // DFB: Set The Content-Type So the Browser Knows How To Render&lt;br /&gt;        // The Response&lt;br /&gt;        using (sqlCommand = new SqlCommand("select ContentType from SingleDataStore where FileGuid='" + fileguid.ToString() + "'", sqlConnection))&lt;br /&gt;        {&lt;br /&gt;            Response.ContentType = sqlCommand.ExecuteScalar().ToString();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // DFB: Writing The Cached File Allows IIS To Stream The Output&lt;br /&gt;        Response.WriteFile(cachePath);&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Subsequent Requests for the Content&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; After the content is in a file in the cache folder, all subsequent requests will either come from the client's browser cache or the web server's cache folder until the content LastModifiedDate changes on the server. Since both situations check the LastModifiedDate in the database before returning the content, you can be sure that only the most current version is displayed on the client. &lt;/p&gt; &lt;p&gt; When the data is updated in the database, the client cache and the web server cache versions will be checked for date freshness and the dirty flag will be set to true. At this point, the entire content will be re-fetched from the database and the file recreated on the file system. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Clearing the Web Server Cache&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Now that the file is in the web server cache with a file name that corresponds to the FileGuid, you can clear out the cache on a schedule of your choosing. You can delete all the contents, all contents before a certain date, or all contents of a certain content type. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Summary&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; This caching system illustrates how to build a database-driven web site using the single storage of a database while still using the cache features of the client and web server. The caches are checked using the If-Modified-Since of the cache content and the LastModifiedDate of the database file in order to deliver the most current data. Once the database content is modified, the cached file is no longer valid. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-5602621393383995880?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5602621393383995880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/5602621393383995880'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/how-to-create-web-server-farm-cache.html' title='How to Create a Web Server Farm Cache'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-4286099484849140933</id><published>2010-01-20T01:46:00.000-08:00</published><updated>2010-01-20T01:49:21.161-08:00</updated><title type='text'>Creating a Data Access Layer for Paging in SQL Server 2005</title><content type='html'>&lt;table border="0" cellpadding="5" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span id="konasapn0"&gt;&lt;p&gt;&lt;table border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="TOP"&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Introduction&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In my previous article, &lt;a href="http://www.15seconds.com/issue/070628.htm"&gt;Paging in SQL Server 2005&lt;/a&gt;, I demonstrated how to support paging the results of a SQL query inside of a stored procedure.  In this two-part article, I will tie that logic to an ASP.NET page with a GridView and DetailsView to demonstrate an efficient way to incorporate paging and updating through an ObjectDataSource.  Along the way we will use the Class Diagram tool and the Web Application Project template (added to Visual Studio 2005 by  &lt;a href="http://msdn2.microsoft.com/en-us/vstudio/bb265237.aspx"&gt;Service Pack 1&lt;/a&gt;), although you are free to use methods you are more comfortable with. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Background&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Visual Studio 2005 introduced a number of tools that allow web developers to create dynamic web pages more easily than ever.  The GridView encapsulates most of the functionality needed for displaying and editing tabular data efficiently, and can bind to several types of data sources.  The DetailsView is a sibling to the GridView, supporting most of the same functionality but displaying a single record at a time.  While these controls can bind to databases through simple DataSets and SqlDataSources, the ObjectDataSource control provides a more clearly defined, more sophisticated -- but potentially more complicated -- connection.  For developers looking to model their SQL data within the application through custom classes, the ObjectDataSource allows them to bind their strongly-typed classes to user controls and add a discrete Business Logic Layer to ensure user interactions follow defined rules of behavior. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Database Layer&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The first order of business is to create a database to work with; the examples below were created in a database called &lt;strong&gt;DALdemo&lt;/strong&gt;, but you can change the connection string to whatever name you choose.  Once you have done this, the following SQL statement will create a simple table to work with: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; CREATE TABLE [dbo].[Person]&lt;br /&gt;(&lt;br /&gt;    [PersonID] [int] IDENTITY(1,1) NOT NULL,&lt;br /&gt;    [FirstName] [nvarchar](50) NOT NULL,&lt;br /&gt;    [MiddleName] [nvarchar](50) NULL,&lt;br /&gt;    [LastName] [nvarchar](50) NOT NULL,&lt;br /&gt;    [Height] [decimal](5, 2) NULL,&lt;br /&gt;CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED&lt;br /&gt;(&lt;br /&gt;    [PersonID] ASC&lt;br /&gt;) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,&lt;br /&gt;    ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]&lt;br /&gt;) ON [PRIMARY] &lt;/code&gt;&lt;/p&gt; &lt;p&gt; To populate the table with some preliminary test data, execute the following SQL statements: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Frank', 'Edward', 'Holiday', 62.38)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Nancy', 'Estelle', 'Walkafeller', 52.81)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Stewart', 'R.', 'Garvey', 61)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Jeff', 'A.', 'Walker', 66.43)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Walter', 'Albert', 'Johnson', 65.66)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Barbara', 'Connie', 'Jones', 65.38)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('William', '', 'Smith', 59.68)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Gillian', 'Kay', 'Krissinger', 62.43)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Sam', '', 'Stuart', 65.67)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Richard', 'G.', 'Harding', 63.98)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Laura', 'Edward', 'Kinsley', 70.56)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Frank', 'Quincy', 'George', 67.31)&lt;br /&gt;INSERT INTO Person (FirstName, MiddleName, LastName, Height) VALUES ('Frank', 'P.', 'Williams', 62.99) &lt;/code&gt;&lt;/p&gt; &lt;p&gt; We will use the following stored procedure to query this table, which incorporates SQL paging logic and uses a ReturnValue parameter to pass back the total number of records. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; CREATE PROCEDURE [dbo].[utilPAGE]&lt;br /&gt;    @datasrc     nvarchar(200)&lt;br /&gt;    ,@orderBy    nvarchar(200)&lt;br /&gt;    ,@startPage  int = 1&lt;br /&gt;    ,@pageSize   int = NULL&lt;br /&gt;    ,@fieldlist  nvarchar(200) = '*'&lt;br /&gt;    ,@filter     nvarchar(200) = ''&lt;br /&gt;AS&lt;br /&gt;    SET NOCOUNT ON&lt;br /&gt;    DECLARE&lt;br /&gt;        @STMT nvarchar(max)            -- SQL to execute&lt;br /&gt;        ,@recct int                    -- total # of records&lt;br /&gt;    SET @recct = -1&lt;br /&gt;    IF LTRIM(RTRIM(@filter)) = '' SET @filter = '1 = 1'&lt;br /&gt;    IF @pageSize IS NULL BEGIN&lt;br /&gt;        SET @STMT = ' SELECT   ' + @fieldlist +&lt;br /&gt;                    ' FROM     ' + @datasrc +&lt;br /&gt;                    ' WHERE    ' + @filter +&lt;br /&gt;                    ' ORDER BY ' + @orderBy&lt;br /&gt;        EXEC (@STMT)                   -- return requested records&lt;br /&gt;    END ELSE BEGIN&lt;br /&gt;        SET @STMT = ' SELECT  @recct = COUNT(*)&lt;br /&gt;                      FROM    ' + @datasrc +&lt;br /&gt;                    ' WHERE   ' + @filter&lt;br /&gt;        EXEC sp_executeSQL @STMT, @params = N'@recct INT OUTPUT', @recct = @recct OUTPUT&lt;br /&gt;&lt;br /&gt;        DECLARE&lt;br /&gt;            @lbound int,&lt;br /&gt;            @ubound int&lt;br /&gt;&lt;br /&gt;        IF @startPage &lt; 1 SET @startPage = 1&lt;br /&gt;        IF @pageSize &lt; 0 SET @pageSize = @pageSize * -1&lt;br /&gt;        IF @pageSize &lt; 1 SET @pageSize = 1&lt;br /&gt;        SET @lbound = ((@startPage - 1) * @pageSize)&lt;br /&gt;        SET @ubound = @lbound + @pageSize + 1&lt;br /&gt;        IF @lbound &gt;= @recct BEGIN&lt;br /&gt;            SET @ubound = @recct + 1&lt;br /&gt;            SET @lbound = @ubound - (@pageSize + 1)   -- return last page of records&lt;br /&gt;        END&lt;br /&gt;        SET @STMT = ' SELECT  ' + @fieldlist +&lt;br /&gt;                    ' FROM (&lt;br /&gt;                      SELECT ROW_NUMBER() OVER(ORDER BY ' + @orderBy + ') AS row, *&lt;br /&gt;                      FROM    ' + @datasrc +&lt;br /&gt;                    ' WHERE   ' + @filter +&lt;br /&gt;                    ' ) AS tbl&lt;br /&gt;                      WHERE  row &gt; ' + CONVERT(varchar(9), @lbound) +&lt;br /&gt;                    ' AND    row &lt; ' + CONVERT(varchar(9), @ubound) + ' '&lt;br /&gt;        EXEC (@STMT)                   -- return requested records&lt;br /&gt;    END&lt;br /&gt;    RETURN @recct &lt;/code&gt;&lt;/p&gt; &lt;p&gt; We will use the PersonSET stored procedure to handle updates to the Person table. PersonSET handles both inserts and updates, with items being inserted if the @ID parameter is less than one: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; CREATE PROCEDURE [dbo].[PersonSET]&lt;br /&gt;(&lt;br /&gt;     @ID int = -1&lt;br /&gt;    ,@FirstName nvarchar(50)&lt;br /&gt;    ,@MiddleName nvarchar(50)&lt;br /&gt;    ,@LastName nvarchar(50)&lt;br /&gt;    ,@Height decimal(5, 2)&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;    SET NOCOUNT ON&lt;br /&gt;    BEGIN TRY&lt;br /&gt;        BEGIN TRANSACTION&lt;br /&gt;        IF @ID &gt; 0 BEGIN&lt;br /&gt;            UPDATE  Person&lt;br /&gt;            SET     FirstName = @FirstName,&lt;br /&gt;                    MiddleName = @MiddleName,&lt;br /&gt;                    LastName = @LastName,&lt;br /&gt;                    Height = @Height&lt;br /&gt;            WHERE   PersonID = @ID;&lt;br /&gt;        END ELSE BEGIN&lt;br /&gt;            INSERT INTO Person (FirstName, MiddleName, LastName, Height)&lt;br /&gt;            VALUES             (@FirstName, @MiddleName, @LastName, @Height);&lt;br /&gt;            SET @ID = SCOPE_IDENTITY()&lt;br /&gt;        END&lt;br /&gt;        COMMIT TRANSACTION&lt;br /&gt;        RETURN @ID&lt;br /&gt;    END TRY&lt;br /&gt;    BEGIN CATCH&lt;br /&gt;        DECLARE&lt;br /&gt;            @ERNUM int&lt;br /&gt;        SELECT @ERNUM = ERROR_NUMBER()&lt;br /&gt;        ROLLBACK TRANSACTION&lt;br /&gt;        IF @ERNUM &gt; 0 SET @ERNUM = -@ERNUM&lt;br /&gt;        RETURN @ERNUM&lt;br /&gt;    END CATCH &lt;/code&gt;&lt;/p&gt; &lt;p&gt; PersonDELETE removes one record at a time from Person, based on the ID field: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; CREATE PROCEDURE PersonDELETE&lt;br /&gt;(&lt;br /&gt;    @ID int = 5&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;    SET NOCOUNT ON&lt;br /&gt;    DELETE FROM Person&lt;br /&gt;    WHERE       PersonID = @ID &lt;/code&gt;&lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Data Object Layer&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The next step is to create a new C# ASP.NET Web Application called &lt;strong&gt;WebApp1&lt;/strong&gt; in Visual Studio.  As shown in Illustration 1, enable the option &lt;strong&gt;Create directory for solution&lt;/strong&gt; and set the Solution Name to &lt;strong&gt;15Seconds&lt;/strong&gt;. This will allow us to work with multiple projects simultaneously. &lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071130_01.gif" width="550" border="0" height="411" /&gt;&lt;br /&gt;&lt;strong&gt;Illustration 1:&lt;/strong&gt; Creating the Web Project and Solution &lt;/p&gt; &lt;p&gt; To create the second project, select &lt;strong&gt;File | New | Project&lt;/strong&gt; and create a new C# Class library called &lt;strong&gt;Library1&lt;/strong&gt;.  Be sure to change the default setting from &lt;strong&gt;Create new Solution&lt;/strong&gt; to &lt;strong&gt;Add to Solution&lt;/strong&gt;, as shown in Illustration 2. &lt;/p&gt; &lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071130_02.gif" width="550" border="0" height="409" /&gt;&lt;br /&gt;&lt;strong&gt;Illustration 2:&lt;/strong&gt; Creating the class project within the solution &lt;/p&gt; &lt;p&gt; Feel free to close and delete the Class1.cs file created automatically by Visual Studio, as we will not be using it.  To create the class we do need, right-click on the Library1 project in the Solution Explorer, select &lt;strong&gt;Add | Class&lt;/strong&gt;, and create a class named &lt;strong&gt;PersonEntity.cs&lt;/strong&gt;. The quickest way to fill in the class is with the Class Editor; in the Solution Explorer, right-click on PersonEntity.cs and select &lt;strong&gt;View Class Diagram&lt;/strong&gt;. &lt;/p&gt; &lt;p&gt; The class needs internal data members for holding values, and we will follow the common practice of prefixing an underscore to their names to avoid confusion later.  To create these, click on the &lt;strong&gt;&lt;add&gt;&lt;/strong&gt; text, type &lt;strong&gt;_ID&lt;/strong&gt;, and press tab.  Set Type to be &lt;strong&gt;int&lt;/strong&gt;, and set modifier to &lt;strong&gt;private&lt;/strong&gt;. Add the next three fields, &lt;strong&gt;_FirstName&lt;/strong&gt;, &lt;strong&gt;_MiddleName&lt;/strong&gt;, and &lt;strong&gt;_LastName&lt;/strong&gt;, all with Type set to &lt;strong&gt;string&lt;/strong&gt;.  Lastly, add field &lt;strong&gt;_Height&lt;/strong&gt; with Type set to &lt;strong&gt;double&lt;/strong&gt;.   &lt;/p&gt; &lt;p&gt; The class needs accessor (set/get) methods so other classes can modify these internal values. To create these, click on the &lt;add&gt; text, type &lt;strong&gt;ID&lt;/strong&gt;, and press tab. Set Type to be &lt;strong&gt;int&lt;/strong&gt;, and set modifier to &lt;strong&gt;public&lt;/strong&gt;. Add the next three properties, called &lt;strong&gt;FirstName&lt;/strong&gt;, &lt;strong&gt;MiddleName&lt;/strong&gt;, and &lt;strong&gt;LastName&lt;/strong&gt;, all with Type set to &lt;strong&gt;string&lt;/strong&gt;.  Lastly, add property &lt;strong&gt;Height&lt;/strong&gt; with Type set to &lt;strong&gt;double&lt;/strong&gt;. &lt;/p&gt; &lt;p&gt; At this point, your class diagram should resemble Illustration 3. &lt;/p&gt; &lt;p&gt; &lt;img src="http://www.15seconds.com/graphics/issue/071130_03.gif" width="550" border="0" height="440" /&gt;&lt;br /&gt;&lt;strong&gt;Illustration 3:&lt;/strong&gt; Creating the PersonEntity skeleton with the Class Diagram tool &lt;/p&gt; &lt;p&gt; Right-click on ClassDiagram1.cd and select &lt;strong&gt;Rename&lt;/strong&gt;; change the name to &lt;strong&gt;diaPersonEntity.cd&lt;/strong&gt;.  Click on the PersonEntity.cs* tab to see what has been happening in the background.  The fields we added will show up as private data members: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     private int _ID;&lt;br /&gt;    private string _FirstName;&lt;br /&gt;    private string _MiddleName;&lt;br /&gt;    private string _LastName;&lt;br /&gt;    private double _Height; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The properties we added show up as public get/set methods.  The ID property is: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     public int ID&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            throw new System.NotImplementedException();&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;        }&lt;br /&gt;    } &lt;/code&gt;&lt;/p&gt; &lt;p&gt;We need to wire the fields and properties together, so that when someone refers to a class property, the relevant field is used. Change the ID property to: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     public int ID&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            &lt;strong&gt;return _ID;&lt;/strong&gt;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            &lt;strong&gt;_ID = value;&lt;/strong&gt;&lt;br /&gt;        }&lt;br /&gt;    } &lt;/code&gt;&lt;/p&gt; &lt;p&gt;Making private data members with public get/set methods probably seems like a lot of extra work, but it is an important part of good design that prevents subtle bugs and supports additional functionality. If a class' internal data members are exposed, other classes may inadvertently modify the internal values without trying. Also, set/get methods allow us to ensure the values used meet any requirements we might have. If, for example, we want to ensure that _ID can only be set to values greater than zero, we can add code in the set method to ensure this: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     public int ID&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return _ID;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            &lt;strong&gt;if(value &gt; 0)&lt;br /&gt;            {&lt;br /&gt;                _ID = value;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                throw new Exception("ID must be greater than zero");&lt;br /&gt;            }&lt;/strong&gt;&lt;br /&gt;        }&lt;br /&gt;    } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Alternatively, if we want the internal values to return an empty string when they are set to null, we can change each of the get methods for string properties to use C#'s &lt;strong&gt;??&lt;/strong&gt; operator.  This is similar to SQL Server's ISNULL() function: if the first value specified is NULL, the second value specified is used instead.  This can be used as shown below: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     public string FirstName&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            &lt;strong&gt;return _FirstName ?? "";&lt;/strong&gt;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            _FirstName = value;&lt;br /&gt;        }&lt;br /&gt;    } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Note that the above code isn't strictly necessary for this project; it is simply an example of things you can do if you want strict validation or other behavior within your custom class (which is the primary benefit of making custom classes). If you still aren't sold on the idea, see &lt;a href="http://msdn2.microsoft.com/en-us/library/65zdfbdt%28VS.71%29.aspx"&gt;http://msdn2.microsoft.com/en-us/library/65zdfbdt(VS.71).aspx&lt;/a&gt; for a more complete explanation of the benefits. &lt;/p&gt; &lt;p&gt; Since we want to access this class from another project, be sure to change the class declaration to: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; namespace Library1&lt;br /&gt;{&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; class PersonEntity&lt;br /&gt;    { &lt;/code&gt;&lt;/p&gt; &lt;p&gt; &lt;span style="font-weight: bold;"&gt;At its simplest, the PersonEntity.cs class should resemble: &lt;/span&gt;&lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; using System;&lt;br /&gt;&lt;br /&gt;namespace Library1&lt;br /&gt;{&lt;br /&gt;    public class PersonEntity&lt;br /&gt;    {&lt;br /&gt;        private int    _ID;&lt;br /&gt;        private string _FirstName;&lt;br /&gt;        private string _MiddleName;&lt;br /&gt;        private string _LastName;&lt;br /&gt;        public double  _Height;&lt;br /&gt;&lt;br /&gt;        public int ID&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _ID;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _ID = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string FirstName&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _FirstName;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _FirstName = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string MiddleName&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _MiddleName ?? "";&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _MiddleName = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string LastName&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _LastName;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _LastName = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public double Height&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _Height;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _Height = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;The Data Access Layer&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt;Continuing to build from the back-end data store towards the user interface, we next need to create the Data Access Layer. The Data Access Layer is a class where you define the connection between an ObjectDataSource, a custom class (in our case, PersonEntity) and the data store for instances of this class (in our case, the Person table in SQL). After you define the relevant methods in the DAL class, you will configure the ObjectDataSource object to use the correct method for each necessary function, and can then set the ASP.NET elements that will use them. &lt;/p&gt; &lt;p&gt; Again, this can seem like a lot of overhead, but the extra work helps to make future maintenance easier. Instead of having specific SQL information embedded in each web page, you will define it once and be able to use it from any page that needs it. When you inevitably need to change your SQL table, you can update the class and DAL instead of editing multiple copies of the same queries throughout your web site. &lt;/p&gt; &lt;p&gt; To prepare the web application, right-click on WebApp1 in Solution Explorer and select &lt;strong&gt;Set As StartUp Project&lt;/strong&gt;.  Next, right-click on References within the WebApp1 project and select &lt;strong&gt;Add Reference&lt;/strong&gt;.  Click on the Projects tab and double-click &lt;strong&gt;Library1&lt;/strong&gt; as a new reference. &lt;/p&gt; &lt;p&gt;Rather than hard-coding the database connection string into our DAL class, we will store it in the web.config, where it can be modified as needed. Note that in a production environment, you should encrypt the database connection string for better security. To add your connection string, double-click the web.config file in the WebApp1 project. Modify it to have the following lines, replacing the user id and password with valid credentials and setting the data source and initial catalog with the host and database name you are using, respectively: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt;     &gt;connectionStrings&gt;&lt;br /&gt;        &gt;add name="15seconds"&lt;br /&gt;            connectionString="user id=demo; pwd=demopass; data source=localhost; initial catalog=15SecondsDAL;"&lt;br /&gt;            providerName="System.Data.SqlClient"&lt;br /&gt;        /&gt;&lt;br /&gt;    &gt;/connectionStrings&gt; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; To create the Data Access Layer class, right-click in the WebApp1 class and select &lt;strong&gt;Add | Add ASP.NET Folder | App_Data&lt;/strong&gt; (this is the standard location for DAL classes). Right-click on the App_Data folder and select &lt;strong&gt;Add | Class&lt;/strong&gt; and set the name to &lt;strong&gt;PersonDAL.cs&lt;/strong&gt;.   &lt;/p&gt; &lt;p&gt;The DAL class must support four standard SQL functions: Select, Insert, Update, and Delete. However, the PersonSET stored procedure actually handles inserts and updates automatically, so we can use the same DAL method for both of these functions. In addition to these functions, the DAL class must return the total number of instances available (in our case, the number of records in the Person table). We will store the record count value returned from the utilPAGE stored procedure, so that when a bound data control needs the total number of records for its paging interface, the DAL will return that value instead of querying the database again. &lt;/p&gt; &lt;p&gt;At run-time, the ObjectDataSource settings will determine which methods to call from your DAL class for select, insert, update, delete, and count, and what information is passed into those methods. We will need to ensure that the ObjectDataSource configuration matches the DAL methods. In fact, enabling and disabling features such as sorting and paging support within the ObjectDataSource will affect which methods are called, so you may need to create overloaded versions of your DAL methods depending on the combinations of features you intend to support. In this example, however, we will include support for sorting and paging and will create methods which meet these needs. &lt;/p&gt; &lt;p&gt; A straightforward implementation of the PersonDAL class is shown below. The System.ComponentModel library lets us add declarative attributes to the source code that will help the .NET compiler catch any mistakes we might make with the DAL methods, and will help when the ObjectDataSource is deciding which DAL method to use. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.Configuration;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using Library1;&lt;br /&gt;using WebApp1;&lt;br /&gt;&lt;br /&gt;namespace WebApp1.App_Data&lt;br /&gt;{&lt;br /&gt;    [DataObject]&lt;br /&gt;    public class PersonDAL&lt;br /&gt;    {&lt;br /&gt;        private int _count = 0;&lt;br /&gt;&lt;br /&gt;        [DataObjectMethod(DataObjectMethodType.Select)]&lt;br /&gt;        public List&lt;personentity&gt; Select(int startRecIdx, int maxRows, String sortedBy)&lt;br /&gt;        {&lt;br /&gt;            List&lt;personentity&gt; records = new List&lt;personentity&gt;();&lt;br /&gt;            SqlConnection conn = null;&lt;br /&gt;            SqlDataReader dr = null;&lt;br /&gt;            SqlParameter ret = null;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["15seconds"].ConnectionString);&lt;br /&gt;                conn.Open();&lt;br /&gt;                SqlCommand cmd = new SqlCommand("utilPAGE", conn);&lt;br /&gt;                cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;                if(String.IsNullOrEmpty(sortedBy))&lt;br /&gt;                {&lt;br /&gt;                    sortedBy = "LastName";&lt;br /&gt;                }&lt;br /&gt;                int startpg = (startRecIdx / maxRows) + 1;&lt;br /&gt;                cmd.Parameters.AddWithValue("@datasrc", "Person");&lt;br /&gt;                cmd.Parameters.AddWithValue("@orderBy", sortedBy);&lt;br /&gt;                cmd.Parameters.AddWithValue("@startPage", startpg);&lt;br /&gt;                cmd.Parameters.AddWithValue("@pageSize", maxRows);&lt;br /&gt;                ret = new SqlParameter("ReturnValue", SqlDbType.Int);&lt;br /&gt;                ret.Direction = ParameterDirection.ReturnValue;&lt;br /&gt;                cmd.Parameters.Add(ret);&lt;br /&gt;                dr = cmd.ExecuteReader();&lt;br /&gt;                while(dr.Read())&lt;br /&gt;                {&lt;br /&gt;                    PersonEntity item = new PersonEntity();&lt;br /&gt;                    item.ID = (int)dr["PersonID"];&lt;br /&gt;                    item.FirstName = dr["FirstName"].ToString();&lt;br /&gt;                    item.MiddleName = dr["MiddleName"].ToString();&lt;br /&gt;                    item.LastName = dr["LastName"].ToString();&lt;br /&gt;                    //item.Height = (double)(dr["Height"] ?? 0.0);&lt;br /&gt;                    item.Height = Convert.ToDouble(dr["Height"].ToString());&lt;br /&gt;                    records.Add(item);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                if(dr != null)&lt;br /&gt;                {&lt;br /&gt;                    dr.Close();&lt;br /&gt;                }&lt;br /&gt;                if(conn != null)&lt;br /&gt;                {&lt;br /&gt;                    conn.Close();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            _count = Convert.ToInt32(ret.Value);&lt;br /&gt;            return records;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [DataObjectMethod(DataObjectMethodType.Update)]&lt;br /&gt;        public static bool Update(PersonEntity item)&lt;br /&gt;        {&lt;br /&gt;            bool retval = false;&lt;br /&gt;            SqlConnection conn = null;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["15seconds"].ConnectionString);&lt;br /&gt;                conn.Open();&lt;br /&gt;                SqlCommand cmd = new SqlCommand("PersonSET", conn);&lt;br /&gt;                cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;                cmd.Parameters.AddWithValue("@ID", item.ID);&lt;br /&gt;                cmd.Parameters.AddWithValue("@FirstName", item.FirstName);&lt;br /&gt;                cmd.Parameters.AddWithValue("@MiddleName", item.MiddleName);&lt;br /&gt;                cmd.Parameters.AddWithValue("@LastName", item.LastName);&lt;br /&gt;                cmd.Parameters.AddWithValue("@Height", item.Height);&lt;br /&gt;                SqlParameter ret = new SqlParameter("ReturnValue", SqlDbType.Int);&lt;br /&gt;                ret.Direction = ParameterDirection.ReturnValue;&lt;br /&gt;                cmd.Parameters.Add(ret);&lt;br /&gt;                cmd.ExecuteNonQuery();&lt;br /&gt;                int result = Convert.ToInt32(ret.Value);&lt;br /&gt;                retval = result &gt; 0;&lt;br /&gt;            }&lt;br /&gt;            catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                if(conn != null)&lt;br /&gt;                {&lt;br /&gt;                conn.Close();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return retval;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [DataObjectMethod(DataObjectMethodType.Delete)]&lt;br /&gt;        public static bool Delete(PersonEntity item)&lt;br /&gt;        {&lt;br /&gt;            bool retval = false;&lt;br /&gt;            SqlConnection conn = null;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["15seconds"].ConnectionString);&lt;br /&gt;                conn.Open();&lt;br /&gt;                SqlCommand cmd = new SqlCommand("PersonDELETE", conn);&lt;br /&gt;                cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;                cmd.Parameters.AddWithValue("@ID", item.ID);&lt;br /&gt;                SqlParameter ret = new SqlParameter("ReturnValue", SqlDbType.Int);&lt;br /&gt;                ret.Direction = ParameterDirection.ReturnValue;&lt;br /&gt;                cmd.Parameters.Add(ret);&lt;br /&gt;                cmd.ExecuteNonQuery();&lt;br /&gt;                int result = Convert.ToInt32(ret.Value);&lt;br /&gt;                retval = result &gt; 0;&lt;br /&gt;            }&lt;br /&gt;            catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                if(conn != null)&lt;br /&gt;                {&lt;br /&gt;                    conn.Close();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return retval;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public int GetRecordCount(int startRecIdx, int maxRows, string sortedBy)&lt;br /&gt;        {&lt;br /&gt;            return _count;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public int GetRecordCount()&lt;br /&gt;        {&lt;br /&gt;            return _count;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The Select method begins by creating an empty List collection that can hold PersonEntity objects. After declaring some ADO.NET objects, the code enters a &lt;strong&gt;try&lt;/strong&gt; block.  This is important, as any SQL objects used in this method need to be closed properly whether the method succeeds or fails.  A connection is created based on the web.config connection string entry named 15seconds, and preparations are made for running the utilPAGE stored procedure.  Because utilPAGE needs to have a non-blank orderBy argument, the LastName field is used as a default if nothing else is supplied.  The parameters for table name, sort field list, starting page number, and page size are added, as is a ReturnValue parameter that will receive anything which the stored procedure explicitly sends with a &lt;strong&gt;return&lt;/strong&gt; statement.  The query is executed, the results are converted into new PersonEntity objects, and the PersonEntity objects are added to the List&lt;personentity&gt; collection.  The SQL objects are properly closed in the &lt;strong&gt;finally&lt;/strong&gt; clause, and (because the return value can only be accessed after the SqlDataReader object is closed) the return value is stored in _count. &lt;/p&gt; &lt;p&gt; The Update method receives a PersonEntity object when it is called. Because the only difference between an Insert and an Update will be the value of the ID field in this object, we will treat both the same and let the stored procedure handle the necessary logic. The Update method will largely imitate the Select method, except that the stored procedure and arguments are different and no result set will be processed. The return value will be checked to see if the update succeeded, with numbers less than one indicating an error. &lt;/p&gt; &lt;p&gt;The Delete method receives a PersonEntity object when it is called, however only the ID field will be populated. (What fields are populated for this is controlled by the DataKeyNames property, which we will see later.) The Delete method is nearly identical to the Update method, except for the stored procedure and arguments. The return value will be checked to see if the delete succeeded, with numbers less than one indicating an error. &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-weight: bold;"&gt;     &lt;span class="clsTitle"&gt;Conclusion&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; The work so far has focused on laying a foundation, and just as with building an actual foundation, there has been a lot of critical activity but little in the way of visible results.  In the second part of this article, we will create an interactive web page with very little code that uses everything created so far. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt; &lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;!--content_stop--&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt; &lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;         &lt;!-- AUTHOR SECTION --&gt;        &lt;!-- /AUTHOR SECTION --&gt;       &lt;/p&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/p&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=0&amp;amp;o=0&amp;amp;e=26&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;t=15+Seconds+%3A+Creating+a+Data+Access+Layer+for+Paging+in+SQL+Server+2005&amp;amp;m1=ASP+%2C+VBScript+%2C+XML+%2C+SOAP+%2C+ASP.NET+%2C+.NET+%2C+IIS+%2C+SQL+%2C+VB+%2C+COM+%2C+active+server+pages+%2C+database+%2C+ADSI+%2C+ISAPI&amp;amp;m2=In+this+two-part+article+%2C+David+Beahm+builds+upon+his+previous+SQL+Server+2005+paging+solution+.+Part+one+covers+creating+a+data+access+layer+that+provides+an+efficient+way+to+incorporate+paging+and+updating+into+an+ASP.NET+application+via+the+ObjectDataSource+control+.&amp;amp;ps=7639&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=+_+Pioneering+Active+Server+_+L+2+_+15+Seconds+Weekly+Newsletter+_+%u2022+Complete+Coverage+@+%u2022+Site+Updates+@+%u2022+Upcoming+Features+_+L+1+_+L+1+_+L+2+_+internet.commerce+_+L+1+_+Creating+a+Data+Access+Layer+for+Paging+in+SQL+Server+2005+@+By+David+Beahm+_+L+1+@+4.2+@+out+of+5+_+L+1+@+Microsoft%27s+Windows+Server+2008+R2+may+sound+like+it%27s+simply+an+updated+release+of+Windows+Server+2008+%2C+but+it+goes+far+beyond+that+%3A+it+includes+many+new+features+and+technical+innovations+that+were+not+available+in+the+previous+release+.+@+CASE+STUDY+%3A+@+Microsoft+has+a+range+of+Core+Infrastructure+technologies+that+can+best+help+companies+save+money+and+drive+operational+efficiency+.+@+TRIAL+SOFTWARE+%3A+@+Evaluate+Windows+Server+2008+R2+free+for+180+days+.+_+MARKETPLACE+_+L+1+_+In+my+previous+article+%2C++@+%2C+I+demonstrated+how+to+support+paging+the+results+of+a+SQL+query+inside+of+a+stored+procedure+.+In+this+two-part+article+%2C+I+will+tie+that+logic+to+an+ASP.NET+page+with+a+GridView+and+DetailsView+to+demonstrate+an+efficient+way+to+incorporate+paging+and+updating+through+an+ObjectDataSource+.+Along+the+way+we+will+use+the+Class+Diagram+tool+and+the+Web+Application+Project+template+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=1&amp;amp;o=1211&amp;amp;e=41&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+%28+added+to+Visual+Studio+2005+by++@+%29%2C+although+you+are+free+to+use+methods+you+are+more+comfortable+with+.+_+L+1+_+Visual+Studio+2005+introduced+a+number+of+tools+that+allow+web+developers+to+create+dynamic+web+pages+more+easily+than+ever+.+The+GridView+encapsulates+most+of+the+functionality+needed+for+displaying+and+editing+tabular+data+efficiently+%2C+and+can+bind+to+several+types+of+data+sources+.+The+DetailsView+is+a+sibling+to+the+GridView+%2C+supporting+most+of+the+same+functionality+but+displaying+a+single+record+at+a+time+.+While+these+controls+can+bind+to+databases+through+simple+DataSets+and+SqlDataSources+%2C+the+ObjectDataSource+control+provides+a+more+clearly+defined+%2C+more+sophisticated+--+but+potentially+more+complicated+--+connection+.+For+developers+looking+to+model+their+SQL+data+within+the+application+through+custom+classes+%2C+the+ObjectDataSource+allows+them+to+bind+their+strongly-typed+classes+to+user+controls+and+add+a+discrete+Business+Logic+Layer+to+ensure+user+interactions+follow+defined+rules+of+behavior+.+_+The+Database+Layer+_+The+first+order+of+business+is+to+create+a+database+to+work+with%3B+the+examples+below+were+created+in+a+database+called+@+DALdemo+@+%2C+but+you+can+change+the+connection+string+to+whatever+name+you+choose+.+Once+you+have+done+this+%2C+the+following+SQL+statement+will+create+a+simple+table+to+work+with+%3A+_+CREATE+TABLE+%5Bdbo%5D.%5BPerson%5D+@+%5BPersonID%5D+%5Bint%5D+IDENTITY%281+%2C+1+%29+NOT+NULL+%2C+@+%5BFirstName%5D+%5Bnvarchar%5D%2850+%29+NOT+NULL+%2C+@+%5BMiddleName%5D+%5Bnvarchar%5D%2850+%29+NULL+%2C+@+%5BLastName%5D+%5Bnvarchar%5D%2850+%29+NOT+NULL+%2C+@+%5BHeight%5D+%5Bdecimal%5D%285+%2C+2+%29+NULL+%2C+@+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=2&amp;amp;o=2918&amp;amp;e=57&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+CONSTRAINT+%5BPK_Person%5D+PRIMARY+KEY+CLUSTERED+@+%5BPersonID%5D+ASC+@+%29+WITH+%28+PAD_INDEX+%3D+OFF+%2C+STATISTICS_NORECOMPUTE+%3D+OFF+%2C+IGNORE_DUP_KEY+%3D+OFF+%2C+@+ALLOW_ROW_LOCKS+%3D+ON+%2C+ALLOW_PAGE_LOCKS+%3D+ON+%29+ON+%5BPRIMARY%5D+@+%29+ON+%5BPRIMARY%5D+_+To+populate+the+table+with+some+preliminary+test+data+%2C+execute+the+following+SQL+statements+%3A+_+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Frank%27%2C+%27Edward%27%2C+%27Holiday%27%2C+62.38+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Nancy%27%2C+%27Estelle%27%2C+%27Walkafeller%27%2C+52.81+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Stewart%27%2C+%27R.%27%2C+%27Garvey%27%2C+61+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Jeff%27%2C+%27A.%27%2C+%27Walker%27%2C+66.43+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Walter%27%2C+%27Albert%27%2C+%27Johnson%27%2C+65.66+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Barbara%27%2C+%27Connie%27%2C+%27Jones%27%2C+65.38+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27William%27%2C+%27%27%2C+%27Smith%27%2C+59.68+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Gillian%27%2C+%27Kay%27%2C+%27Krissinger%27%2C+62.43+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Sam%27%2C+%27%27%2C+%27Stuart%27%2C+65.67+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=3&amp;amp;o=4621&amp;amp;e=87&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Richard%27%2C+%27G.%27%2C+%27Harding%27%2C+63.98+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Laura%27%2C+%27Edward%27%2C+%27Kinsley%27%2C+70.56+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Frank%27%2C+%27Quincy%27%2C+%27George%27%2C+67.31+%29+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+VALUES+%28%27Frank%27%2C+%27P.%27%2C+%27Williams%27%2C+62.99+%29+_+We+will+use+the+following+stored+procedure+to+query+this+table+%2C+which+incorporates+SQL+paging+logic+and+uses+a+ReturnValue+parameter+to+pass+back+the+total+number+of+records+.+_+CREATE+PROCEDURE+%5Bdbo%5D.%5ButilPAGE%5D+@+@datasrc+nvarchar%28200+%29+@+%2C@orderBy+nvarchar%28200+%29+@+%2C@startPage+int+%3D+1+@+%2C@pageSize+int+%3D+NULL+@+%2C@fieldlist+nvarchar%28200+%29+%3D+%27*%27+@+%2C@filter+nvarchar%28200+%29+%3D+%27%27+@+AS+@+SET+NOCOUNT+ON+@+DECLARE+@+@STMT+nvarchar%28max+%29+--+SQL+to+execute+@+%2C@recct+int+--+total+%23+of+records+@+SET+@recct+%3D+-1+@+IF+LTRIM%28RTRIM%28@filter%29%29+%3D+%27%27+SET+@filter+%3D+%271+%3D+1+%27+@+IF+@pageSize+IS+NULL+BEGIN+@+SET+@STMT+%3D+%27+SELECT+%27+++@fieldlist+++@+%27+FROM+%27+++@datasrc+++@+%27+WHERE+%27+++@filter+++@+%27+ORDER+BY+%27+++@orderBy+@+EXEC+%28@STMT+%29+--+return+requested+records+@+END+ELSE+BEGIN+@+SET+@STMT+%3D+%27+SELECT+@recct+%3D+COUNT%28*%29+@+FROM+%27+++@datasrc+++@+%27+WHERE+%27+++@filter+@+EXEC+sp_executeSQL+@STMT+%2C+@params+%3D+N%27@recct+INT+OUTPUT%27%2C+@recct+%3D+@recct+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=4&amp;amp;o=6224&amp;amp;e=127&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+OUTPUT+@+DECLARE+@+@lbound+int+%2C+@+@ubound+int+@+IF+@startPage+%3C+1+SET+@startPage+%3D+1+@+IF+@pageSize+%3C+0+SET+@pageSize+%3D+@pageSize+*+-1+@+IF+@pageSize+%3C+1+SET+@pageSize+%3D+1+@+SET+@lbound+%3D+%28%28@startPage+-+1+%29+*+@pageSize+%29+@+SET+@ubound+%3D+@lbound+++@pageSize+++1+@+IF+@lbound+%3E%3D+@recct+BEGIN+@+SET+@ubound+%3D+@recct+++1+@+SET+@lbound+%3D+@ubound+-+%28@pageSize+++1+%29+--+return+last+page+of+records+@+END+@+SET+@STMT+%3D+%27+SELECT+%27+++@fieldlist+++@+%27+FROM+%28+@+SELECT+ROW_NUMBER%28%29+OVER%28ORDER+BY+%27+++@orderBy+++%27%29+AS+row+%2C+*+@+FROM+%27+++@datasrc+++@+%27+WHERE+%27+++@filter+++@+%27+%29+AS+tbl+@+WHERE+row+%3E+%27+++CONVERT%28varchar%289%29%2C+@lbound+%29+++@+%27+AND+row+%3C+%27+++CONVERT%28varchar%289%29%2C+@ubound+%29+++%27+%27+@+EXEC+%28@STMT+%29+--+return+requested+records+@+END+@+RETURN+@recct+_+We+will+use+the+PersonSET+stored+procedure+to+handle+updates+to+the+Person+table+.+PersonSET+handles+both+inserts+and+updates+%2C+with+items+being+inserted+if+the+@ID+parameter+is+less+than+one+%3A+_+CREATE+PROCEDURE+%5Bdbo%5D.%5BPersonSET%5D+@+@ID+int+%3D+-1+@+%2C@FirstName+nvarchar%2850+%29+@+%2C@MiddleName+nvarchar%2850+%29+@+%2C@LastName+nvarchar%2850+%29+@+%2C@Height+decimal%285+%2C+2+%29+@+AS+@+SET+NOCOUNT+ON+@+BEGIN+TRY+@+BEGIN+TRANSACTION+@+IF+@ID+%3E+0+BEGIN+@+UPDATE+Person+@+SET+FirstName+%3D+@FirstName+%2C+@+MiddleName+%3D+@MiddleName+%2C+@+LastName+%3D+@LastName+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=5&amp;amp;o=7662&amp;amp;e=175&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+%2C+@+Height+%3D+@Height+@+WHERE+PersonID+%3D+@ID%3B+@+END+ELSE+BEGIN+@+INSERT+INTO+Person+%28+FirstName+%2C+MiddleName+%2C+LastName+%2C+Height+%29+@+VALUES+%28@FirstName+%2C+@MiddleName+%2C+@LastName+%2C+@Height%29%3B+@+SET+@ID+%3D+SCOPE_IDENTITY%28%29+@+END+@+COMMIT+TRANSACTION+@+RETURN+@ID+@+END+TRY+@+BEGIN+CATCH+@+DECLARE+@+@ERNUM+int+@+SELECT+@ERNUM+%3D+ERROR_NUMBER%28%29+@+ROLLBACK+TRANSACTION+@+IF+@ERNUM+%3E+0+SET+@ERNUM+%3D+-@ERNUM+@+RETURN+@ERNUM+@+END+CATCH+_+PersonDELETE+removes+one+record+at+a+time+from+Person+%2C+based+on+the+ID+field+%3A+_+CREATE+PROCEDURE+PersonDELETE+@+@ID+int+%3D+5+@+AS+@+SET+NOCOUNT+ON+@+DELETE+FROM+Person+@+WHERE+PersonID+%3D+@ID+_+The+Data+Object+Layer+_+The+next+step+is+to+create+a+new+C%23+ASP.NET+Web+Application+called+@+WebApp1+@+in+Visual+Studio+.+As+shown+in+Illustration+1+%2C+enable+the+option+@+Create+directory+for+solution+@+and+set+the+Solution+Name+to+@+15Seconds+@+.+This+will+allow+us+to+work+with+multiple+projects+simultaneously+.+_+L+1+@+Creating+the+Web+Project+and+Solution+_+To+create+the+second+project+%2C+select+@+File+%7C+New+%7C+Project+@+and+create+a+new+C%23+Class+library+called+@+Library1+@+.+Be+sure+to+change+the+default+setting+from+@+Create+new+Solution+@+to+@+Add+to+Solution+@+%2C+as+shown+in+Illustration+2+.+_+L+1+@+Creating+the+class+project+within+the+solution++_+Feel+free+to+close+and+delete+the+Class1.cs+file+created+automatically+by+Visual+Studio+%2C+as+we+will+not+be+using+it+.+To+create+the+class+we+do+need+%2C+right-click+on+the+Library1+project+in+the+Solution+Explorer+%2C+select+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=6&amp;amp;o=9243&amp;amp;e=230&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_++@+Add+%7C+Class+@+%2C+and+create+a+class+named+@+PersonEntity.cs+@+.+The+quickest+way+to+fill+in+the+class+is+with+the+Class+Editor%3B+in+the+Solution+Explorer+%2C+right-click+on+PersonEntity.cs+and+select+@+View+Class+Diagram+_+The+class+needs+internal+data+members+for+holding+values+%2C+and+we+will+follow+the+common+practice+of+prefixing+an+underscore+to+their+names+to+avoid+confusion+later+.+To+create+these+%2C+click+on+the+@+%3Cadd+field%3E+@+text+%2C+type+@+_ID+@+%2C+and+press+tab+.+Set+Type+to+be+@+int+@+%2C+and+set+modifier+to+@+private+@+.+Add+the+next+three+fields+%2C+@+_FirstName+@+_MiddleName+@+%2C+and+@+_LastName+@+%2C+all+with+Type+set+to+@+string+@+.+Lastly+%2C+add+field+@+_Height+@+with+Type+set+to+@+double+_+The+class+needs+accessor+%28+set/get+%29+methods+so+other+classes+can+modify+these+internal+values+.+To+create+these+%2C+click+on+the+%3Cadd+property%3E+text+%2C+type+@+ID+@+%2C+and+press+tab+.+Set+Type+to+be+@+int+@+%2C+and+set+modifier+to+@+public+@+.+Add+the+next+three+properties+%2C+called+@+FirstName+@+MiddleName+@+%2C+and+@+LastName+@+%2C+all+with+Type+set+to+@+string+@+.+Lastly+%2C+add+property+@+Height+@+with+Type+set+to+@+double+_+At+this+point+%2C+your+class+diagram+should+resemble+Illustration+3+.+_+L+1+@+Creating+the+PersonEntity+skeleton+with+the+Class+Diagram+tool+_+Right-click+on+ClassDiagram1.cd+and+select+@+Rename+@+%3B+change+the+name+to+@+diaPersonEntity.cd+@+.+Click+on+the+PersonEntity.cs*+tab+to+see+what+has+been+happening+in+the+background+.+The+fields+we+added+will+show+up+as+private+data+members+%3A+_+private+int+_ID%3B+@+private+string+_FirstName%3B+@+private+string+_MiddleName%3B+@+private+string+_LastName%3B+@+private+double+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=7&amp;amp;o=10946&amp;amp;e=259&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+_Height%3B++_+The+properties+we+added+show+up+as+public+get/set+methods+.+The+ID+property+is+%3A++_+public+int+ID+@+get+@+throw+new+System.NotImplementedException%28%29%3B+@+set+_+We+need+to+wire+the+fields+and+properties+together+%2C+so+that+when+someone+refers+to+a+class+property+%2C+the+relevant+field+is+used+.+Change+the+ID+property+to+%3A+_+public+int+ID+@+get+@+return+_ID%3B+@+set+@+_ID+%3D+value%3B+_+Making+private+data+members+with+public+get/set+methods+probably+seems+like+a+lot+of+extra+work+%2C+but+it+is+an+important+part+of+good+design+that+prevents+subtle+bugs+and+supports+additional+functionality+.+If+a+class+%27+internal+data+members+are+exposed+%2C+other+classes+may+inadvertently+modify+the+internal+values+without+trying+.+Also+%2C+set/get+methods+allow+us+to+ensure+the+values+used+meet+any+requirements+we+might+have+.+If+%2C+for+example+%2C+we+want+to+ensure+that+_ID+can+only+be+set+to+values+greater+than+zero+%2C+we+can+add+code+in+the+set+method+to+ensure+this+%3A+_+public+int+ID+@+get+@+return+_ID%3B+@+set+@+if%28value+%3E+0+%29+@+_ID+%3D+value%3B+@+else+@+throw+new+Exception%28%22ID+must+be+greater+than+zero%22%29%3B+_+Alternatively+%2C+if+we+want+the+internal+values+to+return+an+empty+string+when+they+are+set+to+null+%2C+we+can+change+each+of+the+get+methods+for+string+properties+to+use+C%23%27s+@+%3F%3F+@+operator+.+This+is+similar+to+SQL+Server%27s+ISNULL%28%29+function+%3A+if+the+first+value+specified+is+NULL+%2C+the+second+value+specified+is+used+instead+.+This+can+be+used+as+shown+below+%3A+_+public+string+FirstName+@+get+@+return+_FirstName+%3F%3F+%22%22%3B+@+set+@+_FirstName+%3D+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=8&amp;amp;o=12583&amp;amp;e=302&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+value%3B+_+Note+that+the+above+code+isn%27t+strictly+necessary+for+this+project%3B+it+is+simply+an+example+of+things+you+can+do+if+you+want+strict+validation+or+other+behavior+within+your+custom+class+%28+which+is+the+primary+benefit+of+making+custom+classes%29.+If+you+still+aren%27t+sold+on+the+idea+%2C+see+@+for+a+more+complete+explanation+of+the+benefits+.+_+Since+we+want+to+access+this+class+from+another+project+%2C+be+sure+to+change+the+class+declaration+to+%3A+_+namespace+Library1+@+public+@+class+PersonEntity+_+At+its+simplest+%2C+the+PersonEntity.cs+class+should+resemble+%3A+_+L+2+@+namespace+Library1+@+public+class+PersonEntity+@+private+int+_ID%3B+@+private+string+_FirstName%3B+@+private+string+_MiddleName%3B+@+private+string+_LastName%3B+@+public+double+_Height%3B+@+public+int+ID+@+get+@+return+_ID%3B+@+set+@+_ID+%3D+value%3B+@+public+string+FirstName+@+get+@+return+_FirstName%3B+@+set+@+_FirstName+%3D+value%3B+@+public+string+MiddleName+@+get+@+return+_MiddleName+%3F%3F+%22%22%3B+@+set+@+_MiddleName+%3D+value%3B+@+public+string+LastName+@+get+@+return+_LastName%3B+@+set+@+_LastName+%3D+value%3B+@+public+double+Height+@+get+@+return+_Height%3B+@+set+@+_Height+%3D+value%3B+_+The+Data+Access+Layer+_+Continuing+to+build+from+the+back-end+data+store+towards+the+user+interface+%2C+we+next+need+to+create+the+Data+Access+Layer+.+The+Data+Access+Layer+is+a+class+where+you+define+the+connection+between+an+ObjectDataSource+%2C+a+custom+class+%28+in+our+case+%2C+PersonEntity+%29+and+the+data+store+for+instances+of+this+class+%28+in+our+case+%2C+the+Person+table+in+SQL%29.+After+you+define+the+relevant+methods+in+the+DAL+class+%2C+you+will+configure+the+ObjectDataSource+object+to+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=9&amp;amp;o=14293&amp;amp;e=319&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_+use+the+correct+method+for+each+necessary+function+%2C+and+can+then+set+the+ASP.NET+elements+that+will+use+them+.++_+Again+%2C+this+can+seem+like+a+lot+of+overhead+%2C+but+the+extra+work+helps+to+make+future+maintenance+easier+.+Instead+of+having+specific+SQL+information+embedded+in+each+web+page+%2C+you+will+define+it+once+and+be+able+to+use+it+from+any+page+that+needs+it+.+When+you+inevitably+need+to+change+your+SQL+table+%2C+you+can+update+the+class+and+DAL+instead+of+editing+multiple+copies+of+the+same+queries+throughout+your+web+site+.+_+To+prepare+the+web+application+%2C+right-click+on+WebApp1+in+Solution+Explorer+and+select+@+Set+As+StartUp+Project+@+.+Next+%2C+right-click+on+References+within+the+WebApp1+project+and+select+@+Add+Reference+@+.+Click+on+the+Projects+tab+and+double-click+@+Library1+@+as+a+new+reference+.+_+Rather+than+hard-coding+the+database+connection+string+into+our+DAL+class+%2C+we+will+store+it+in+the+web.config+%2C+where+it+can+be+modified+as+needed+.+Note+that+in+a+production+environment+%2C+you+should+encrypt+the+database+connection+string+for+better+security+.+To+add+your+connection+string+%2C+double-click+the+web.config+file+in+the+WebApp1+project+.+Modify+it+to+have+the+following+lines+%2C+replacing+the+user+id+and+password+with+valid+credentials+and+setting+the+data+source+and+initial+catalog+with+the+host+and+database+name+you+are+using+%2C+respectively+%3A+_+%3CconnectionStrings%3E+@+%3Cadd+name%3D%2215seconds+%22+@+connectionString%3D%22user+id%3Ddemo%3B+pwd%3Ddemopass%3B+data+source%3Dlocalhost%3B+initial+catalog%3D15SecondsDAL%3B%22+@+providerName%3D%22System.Data.SqlClient+%22+@+/%3E+@+%3C/connectionStrings%3E++_+To+create+the+Data+Access+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=10&amp;amp;o=16002&amp;amp;e=328&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_+Layer+class+%2C+right-click+in+the+WebApp1+class+and+select++@+Add+%7C+Add+ASP.NET+Folder+%7C+App_Data+@+%28+this+is+the+standard+location+for+DAL+classes%29.+Right-click+on+the+App_Data+folder+and+select+@+Add+%7C+Class+@+and+set+the+name+to+@+PersonDAL.cs+_+The+DAL+class+must+support+four+standard+SQL+functions+%3A+Select+%2C+Insert+%2C+Update+%2C+and+Delete+.+However+%2C+the+PersonSET+stored+procedure+actually+handles+inserts+and+updates+automatically+%2C+so+we+can+use+the+same+DAL+method+for+both+of+these+functions+.+In+addition+to+these+functions+%2C+the+DAL+class+must+return+the+total+number+of+instances+available+%28+in+our+case+%2C+the+number+of+records+in+the+Person+table%29.+We+will+store+the+record+count+value+returned+from+the+utilPAGE+stored+procedure+%2C+so+that+when+a+bound+data+control+needs+the+total+number+of+records+for+its+paging+interface+%2C+the+DAL+will+return+that+value+instead+of+querying+the+database+again+.+_+At+run-time+%2C+the+ObjectDataSource+settings+will+determine+which+methods+to+call+from+your+DAL+class+for+select+%2C+insert+%2C+update+%2C+delete+%2C+and+count+%2C+and+what+information+is+passed+into+those+methods+.+We+will+need+to+ensure+that+the+ObjectDataSource+configuration+matches+the+DAL+methods+.+In+fact+%2C+enabling+and+disabling+features+such+as+sorting+and+paging+support+within+the+ObjectDataSource+will+affect+which+methods+are+called+%2C+so+you+may+need+to+create+overloaded+versions+of+your+DAL+methods+depending+on+the+combinations+of+features+you+intend+to+support+.+In+this+example+%2C+however+%2C+we+will+include+support+for+sorting+and+paging+and+will+create+methods+which+meet+these+needs+.++_+A+straightforward+implementation+of+the+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=11&amp;amp;o=17711&amp;amp;e=363&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_+PersonDAL+class+is+shown+below+.+The+System.ComponentModel+library+lets+us+add+declarative+attributes+to+the+source+code+that+will+help+the+.NET+compiler+catch+any+mistakes+we+might+make+with+the+DAL+methods+%2C+and+will+help+when+the+ObjectDataSource+is+deciding+which+DAL+method+to+use+.++_+L+2+@+using+System.Collections.Generic%3B+@+using+System.ComponentModel%3B+@+using+System.Configuration%3B+@+using+System.Data%3B+@+using+System.Data.SqlClient%3B+@+using+System.Web%3B+@+using+System.Web.Security%3B+@+using+System.Web.UI%3B+@+using+System.Web.Configuration%3B+@+using+System.Web.UI.WebControls%3B+@+using+System.Web.UI.WebControls.WebParts%3B+@+using+System.Web.UI.HtmlControls%3B+@+using+Library1%3B+@+using+WebApp1%3B+@+namespace+WebApp1.App_Data+@+%5BDataObject%5D+@+public+class+PersonDAL+@+private+int+_count+%3D+0%3B+@+%5BDataObjectMethod%28DataObjectMethodType.Select%29%5D+@+public+List%3CPersonEntity%3E+Select%28int+startRecIdx+%2C+int+maxRows+%2C+String+sortedBy+%29+@+List%3CPersonEntity%3E+records+%3D+new+List%3CPersonEntity%3E%28%29%3B+@+SqlConnection+conn+%3D+null%3B+@+SqlDataReader+dr+%3D+null%3B+@+SqlParameter+ret+%3D+null%3B+@+try+@+conn+%3D+new+SqlConnection%28WebConfigurationManager.ConnectionStrings%5B%2215seconds%22%5D.ConnectionString%29%3B+@+conn.Open%28%29%3B+@+SqlCommand+cmd+%3D+new+SqlCommand%28%22utilPAGE%22%2C+conn%29%3B+@+cmd.CommandType+%3D+CommandType.StoredProcedure%3B+@+if%28String.IsNullOrEmpty%28sortedBy%29%29+@+sortedBy+%3D+%22+LastName%22%3B+@+int+startpg+%3D+%28+startRecIdx+/+maxRows+%29+++1%3B+@+cmd.Parameters.AddWithValue%28%22@datasrc%22%2C+%22+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=12&amp;amp;o=19321&amp;amp;e=397&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+Person%22%29%3B+@+cmd.Parameters.AddWithValue%28%22@orderBy%22%2C+sortedBy%29%3B+@+cmd.Parameters.AddWithValue%28%22@startPage%22%2C+startpg%29%3B+@+cmd.Parameters.AddWithValue%28%22@pageSize%22%2C+maxRows%29%3B+@+ret+%3D+new+SqlParameter%28%22ReturnValue%22%2C+SqlDbType.Int%29%3B+@+ret.Direction+%3D+ParameterDirection.ReturnValue%3B+@+cmd.Parameters.Add%28ret%29%3B+@+dr+%3D+cmd.ExecuteReader%28%29%3B+@+while%28dr.Read%28%29%29+@+PersonEntity+item+%3D+new+PersonEntity%28%29%3B+@+item.ID+%3D+%28+int%29dr%5B%22PersonID%22%5D%3B+@+item.FirstName+%3D+dr%5B%22FirstName%22%5D.ToString%28%29%3B+@+item.MiddleName+%3D+dr%5B%22MiddleName%22%5D.ToString%28%29%3B+@+item.LastName+%3D+dr%5B%22LastName%22%5D.ToString%28%29%3B+@+//item.Height+%3D+%28+double%29%28dr%5B%22Height%22%5D+%3F%3F+0.0%29%3B+@+item.Height+%3D+Convert.ToDouble%28dr%5B%22Height%22%5D.ToString%28%29%29%3B+@+records.Add%28item%29%3B+@+catch%28Exception+ex+%29+@+throw+ex%3B+@+finally+@+if%28dr+%21%3D+null+%29+@+dr.Close%28%29%3B+@+if%28conn+%21%3D+null+%29+@+conn.Close%28%29%3B+@+_count+%3D+Convert.ToInt32%28ret.Value%29%3B+@+return+records%3B+@+%5BDataObjectMethod%28DataObjectMethodType.Update%29%5D+@+public+static+bool+Update%28PersonEntity+item+%29+@+bool+retval+%3D+false%3B+@+SqlConnection+conn+%3D+null%3B+@+try+@+conn+%3D+new+SqlConnection%28WebConfigurationManager.ConnectionStrings%5B%2215seconds%22%5D.ConnectionString%29%3B+@+conn.Open%28%29%3B+@+SqlCommand+cmd+%3D+new+SqlCommand%28%22PersonSET%22%2C+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=13&amp;amp;o=20809&amp;amp;e=429&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+conn%29%3B+@+cmd.CommandType+%3D+CommandType.StoredProcedure%3B+@+cmd.Parameters.AddWithValue%28%22@ID%22%2C+item.ID%29%3B+@+cmd.Parameters.AddWithValue%28%22@FirstName%22%2C+item.FirstName%29%3B+@+cmd.Parameters.AddWithValue%28%22@MiddleName%22%2C+item.MiddleName%29%3B+@+cmd.Parameters.AddWithValue%28%22@LastName%22%2C+item.LastName%29%3B+@+cmd.Parameters.AddWithValue%28%22@Height%22%2C+item.Height%29%3B+@+SqlParameter+ret+%3D+new+SqlParameter%28%22ReturnValue%22%2C+SqlDbType.Int%29%3B+@+ret.Direction+%3D+ParameterDirection.ReturnValue%3B+@+cmd.Parameters.Add%28ret%29%3B+@+cmd.ExecuteNonQuery%28%29%3B+@+int+result+%3D+Convert.ToInt32%28ret.Value%29%3B+@+retval+%3D+result+%3E+0%3B+@+catch%28Exception+ex+%29+@+throw+ex%3B+@+finally+@+if%28conn+%21%3D+null+%29+@+conn.Close%28%29%3B+@+return+retval%3B+@+%5BDataObjectMethod%28DataObjectMethodType.Delete%29%5D+@+public+static+bool+Delete%28PersonEntity+item+%29+@+bool+retval+%3D+false%3B+@+SqlConnection+conn+%3D+null%3B+@+try+@+conn+%3D+new+SqlConnection%28WebConfigurationManager.ConnectionStrings%5B%2215seconds%22%5D.ConnectionString%29%3B+@+conn.Open%28%29%3B+@+SqlCommand+cmd+%3D+new+SqlCommand%28%22PersonDELETE%22%2C+conn%29%3B+@+cmd.CommandType+%3D+CommandType.StoredProcedure%3B+@+cmd.Parameters.AddWithValue%28%22@ID%22%2C+item.ID%29%3B+@+SqlParameter+ret+%3D+new+SqlParameter%28%22ReturnValue%22%2C+SqlDbType.Int%29%3B+@+ret.Direction+%3D+ParameterDirection.ReturnValue%3B+@+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=14&amp;amp;o=22257&amp;amp;e=450&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@+cmd.Parameters.Add%28ret%29%3B+@+cmd.ExecuteNonQuery%28%29%3B+@+int+result+%3D+Convert.ToInt32%28ret.Value%29%3B+@+retval+%3D+result+%3E+0%3B+@+catch%28Exception+ex+%29+@+throw+ex%3B+@+finally+@+if%28conn+%21%3D+null+%29+@+conn.Close%28%29%3B+@+return+retval%3B+@+public+int+GetRecordCount%28int+startRecIdx+%2C+int+maxRows+%2C+string+sortedBy+%29+@+return+_count%3B+@+public+int+GetRecordCount%28%29+@+return+_count%3B+_+The+Select+method+begins+by+creating+an+empty+List+collection+that+can+hold+PersonEntity+objects+.+After+declaring+some+ADO.NET+objects+%2C+the+code+enters+a+@+try+@+block+.+This+is+important+%2C+as+any+SQL+objects+used+in+this+method+need+to+be+closed+properly+whether+the+method+succeeds+or+fails+.+A+connection+is+created+based+on+the+web.config+connection+string+entry+named+15seconds+%2C+and+preparations+are+made+for+running+the+utilPAGE+stored+procedure+.+Because+utilPAGE+needs+to+have+a+non-blank+orderBy+argument+%2C+the+LastName+field+is+used+as+a+default+if+nothing+else+is+supplied+.+The+parameters+for+table+name+%2C+sort+field+list+%2C+starting+page+number+%2C+and+page+size+are+added+%2C+as+is+a+ReturnValue+parameter+that+will+receive+anything+which+the+stored+procedure+explicitly+sends+with+a+@+return+@+statement+.+The+query+is+executed+%2C+the+results+are+converted+into+new+PersonEntity+objects+%2C+and+the+PersonEntity+objects+are+added+to+the+List%3CPersonEntity%3E+collection+.+The+SQL+objects+are+properly+closed+in+the+@+finally+@+clause+%2C+and+%28+because+the+return+value+can+only+be+accessed+after+the+SqlDataReader+object+is+closed+%29+the+return+value+is+stored+in+_count+.+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=15&amp;amp;o=23888&amp;amp;e=460&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=@++_+The+Update+method+receives+a+PersonEntity+object+when+it+is+called+.+Because+the+only+difference+between+an+Insert+and+an+Update+will+be+the+value+of+the+ID+field+in+this+object+%2C+we+will+treat+both+the+same+and+let+the+stored+procedure+handle+the+necessary+logic+.+The+Update+method+will+largely+imitate+the+Select+method+%2C+except+that+the+stored+procedure+and+arguments+are+different+and+no+result+set+will+be+processed+.+The+return+value+will+be+checked+to+see+if+the+update+succeeded+%2C+with+numbers+less+than+one+indicating+an+error+.+_+The+Delete+method+receives+a+PersonEntity+object+when+it+is+called+%2C+however+only+the+ID+field+will+be+populated+.+%28+What+fields+are+populated+for+this+is+controlled+by+the+DataKeyNames+property+%2C+which+we+will+see+later.%29+The+Delete+method+is+nearly+identical+to+the+Update+method+%2C+except+for+the+stored+procedure+and+arguments+.+The+return+value+will+be+checked+to+see+if+the+delete+succeeded+%2C+with+numbers+less+than+one+indicating+an+error+.+_+L+1+_+The+work+so+far+has+focused+on+laying+a+foundation+%2C+and+just+as+with+building+an+actual+foundation+%2C+there+has+been+a+lot+of+critical+activity+but+little+in+the+way+of+visible+results+.+In+the+second+part+of+this+article+%2C+we+will+create+an+interactive+web+page+with+very+little+code+that+uses+everything+created+so+far+.+_+Rate+This+Article+_+L+2+_+L+2+_+L+2+_+While+the+.NET+Framework+made+building+ASP.NET+applications+easier+then+it+had+ever+been+in+the+past+%2C+.NET+2.0+builds+on+that+foundation+in+order+to+take+things+to+the+next+level+.+This+article+shows+you+to+how+to+construct+an+N-Tier+ASP.NET+2.0+Web+application+by+leveraging+the+new+features+of+ASP.NET+2.0+and+SQL+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=16&amp;amp;o=25595&amp;amp;e=467&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_+Server+2005+.++_+With+the+release+of+ASP.NET+2.0+%2C+Microsoft+has+greatly+increased+the+power+of+ASP.NET+by+introducing+a+suite+of+new+features+and+functionalities+.+As+part+of+this+release+%2C+ASP.NET+2.0+also+comes+with+a+host+of+new+special+files+and+folders+that+are+meant+to+be+used+to+implement+a+specific+functionality+.+This+article+examines+these+new+files+and+folders+in+detail+and+provides+examples+that+demonstrate+how+to+utilize+them+to+create+ASP.NET+2.0+applications+.++_+Alex+Homer+continues+his+detailed+look+at+the+major+changes+to+the+DataSet+class+.+In+this+part+%2C+he+looks+at+two+features+that+allow+developers+to+work+with+data+in+a+more+structured+and+efficient+way+when+using+the+DataSet+with+a+SQL+Server+2005+database+server+.+_+Alex+Homer+continues+his+detailed+look+at+the+major+changes+to+the+DataSet+class+.+In+this+part+%2C+he+looks+at+two+features+that+allow+developers+to+work+with+data+in+a+more+structured+and+efficient+way+when+using+the+DataSet+with+a+SQL+Server+2005+database+server+.+_+In+this+article+%2C+Alex+Homer+looks+at+the+changes+between+the+version+1.x+and+version+2.0+DataSet+and+their+associated+classes+%2C+showing+you+how+you+can+take+advantage+of+the+new+features+to+improve+your+applications+%27+capabilities+and+performance+.+_+In+this+article+%2C+Alex+Homer+looks+at+the+changes+between+the+version+1.x+and+version+2.0+DataSet+and+their+associated+classes+%2C+showing+you+how+you+can+take+advantage+of+the+new+features+to+improve+your+applications+%27+capabilities+and+performance+.+_+In+ASP.NET+2.0+and+Visual+Studio+2005+%2C+you+can+quickly+program+custom+authentication+pages+with+the+provided+Membership+Login+controls+.+In+this+article+%2C+Dina+" language="JavaScript"&gt;&lt;/script&gt;&lt;script src="http://kona28.kontera.com/KonaSend.js?u=1263980702644&amp;amp;p=125539&amp;amp;k=http%3A//www.15seconds.com/issue/071130.htmMOZILLA&amp;amp;c=17&amp;amp;ls=1&amp;amp;o=27306&amp;amp;e=468&amp;amp;al=1&amp;amp;bAl=1&amp;amp;i=14&amp;amp;n=0&amp;amp;dc_aff_id=&amp;amp;cl=0&amp;amp;mp=0&amp;amp;rm=1&amp;amp;mod=8731&amp;amp;rt=0&amp;amp;st=1&amp;amp;sj=1&amp;amp;l=http%3A//www.15seconds.com/issue/071130.htm&amp;amp;rId=125539_1263980702644_03659734290358274&amp;amp;prev_page=http%3A//www.google.co.in/reader/view/%3Fhl%3Den%7Ctab%3Dwy&amp;amp;h=_+Fleet+Berry+examines+the+steps+involved+in+using+the+Login+control+with+a+custom+SQL+Server+membership+database+.++_+In+this+article+%2C+Thiru+Thangarathinam+examines+.NET+2.0%27s+new+ClickOnce+deployment+technology+that+is+designed+to+ease+deployment+of+Windows+forms+applications+.+This+new+technology+not+only+provides+an+easy+application+installation+mechanism+%2C+it+also+eases+deployment+of+upgrades+to+existing+applications+.+_+With+ASP.NET+2.0+%2C+Microsoft+has+made+great+strides+in+increasing+developer+productivity+and+has+made+implementing+previously+complex+solutions+relatively+easy+.+Where+this+version+of+ASP.NET+really+shines+%2C+however+%2C+is+in+its+new+administrative+tools+that+allow+developers+to+spend+less+time+managing+the+configuration+of+the+servers+and+software+and+more+time+developing+great+code+.+_+Thiru+Thangarathinam+introduces+ASP.NET+2.0%27s+new+TreeView+control+which+provides+a+seamless+way+to+consume+and+display+information+from+hierarchical+data+sources+.+The+article+discusses+this+new+control+in+depth+and+explains+how+to+use+this+feature+rich+control+in+your+ASP.NET+applications+.+_+Want+to+receive+email+when+the+next+article+is+published+%3F+Just+@+to+sign+up+.+_+Support+the+Active+Server+Industry+_+The+Network+for+Technology+Professionals+@+Search+%3A+_+B+Whitepapers+and+eBooks+_+L+1+_+B+Downloads+and+eKits+_+B+Tutorials+and+Demos" language="JavaScript"&gt;&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;   &lt;tr&gt;   &lt;td&gt; &lt;a name="rate"&gt;&lt;/a&gt; &lt;form action="/dyna/rating/results.asp" method="POST"&gt; &lt;table border="0"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td colspan="3"&gt;&lt;center&gt;&lt;/center&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-4286099484849140933?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4286099484849140933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4286099484849140933'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/creating-data-access-layer-for-paging.html' title='Creating a Data Access Layer for Paging in SQL Server 2005'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6253127828287264285</id><published>2010-01-20T01:33:00.001-08:00</published><updated>2010-01-20T01:33:46.422-08:00</updated><title type='text'>New Object Oriented Features in C# 3.0</title><content type='html'>&lt;span id="konasapn0"&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; With the introduction of C# 3.0, Microsoft has released a number of features that greatly enhance the object oriented programming experience of C# developers. These new features enable you to declare and instantiate objects with a new syntax that is not only intuitive but also simple. In addition, you also have the ability to initialize collection objects and arrays using a single line of code. This article will introduce these features through simple examples and discussion. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Prerequisites&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;ul&gt;&lt;li&gt;Visual Studio 2008 Professional Edition&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Implicitly Typed Local Variables&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Let us start by discussing the implicitly typed local variables feature. &lt;/p&gt; &lt;p&gt; C# 3.0 introduces a new keyword called "var". This new keyword enables you to declare a variable whose type is implicitly inferred from the expression used to initialize the variable. For example, consider the following line of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; var age = 30; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The preceding line initializes the variable age to value 30 and automatically gives it the type of integer.  Note that the variable age is a strongly typed variable (integer in this case) and doesn't carry the overhead of a generic object type such as System.Object class. &lt;/p&gt; &lt;p&gt; Note that the var keyword is not a completely new type and it just signals the compiler to take a look at the right-hand side of the expression to decipher the type. If the right-hand side is an int, the compiler will replace the var keyword with int.  Here are some of the key characteristics of implicitly typed local variables. &lt;/p&gt; &lt;ul&gt;&lt;li&gt;They need to be declared and initialized in the same statement.&lt;/li&gt;&lt;li&gt;They can't be initialized to null.&lt;/li&gt;&lt;li&gt;They can't be used as class members.&lt;/li&gt;&lt;li&gt;They are primarily used to declare anonymous types (which you will see later in this article) as part of a LINQ expression.&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Implicitly Typed Arrays&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In the previous section, you have seen how to use the var keyword for implicitly typing variables. In addition to implicitly declaring variables, you can also use the var keyword for declaring arrays as well. For example, consider the following lines of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; int[] numbers = new int[] { 1, 2, 3, 4, 5};&lt;br /&gt;string[] names = new string[] { "Dave", "Doug", "Jim" }; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; By using the var keyword, you can rewrite the preceding lines of code as follows: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; var numbers = new[] { 1, 2, 3, 4, 5};&lt;br /&gt;var names = new[] { "Dave", Doug, "Jim" }; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The compiler infers the type of the array elements at compile-time by examining the values from the initialization expression.  &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Auto Implemented Properties&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Whenever you declare a class, most of the times the class is used only as a placeholder with getters and setters for holding property values without any additional logic. For example, consider a simple class like the following: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; public class Person&lt;br /&gt;{&lt;br /&gt;    int _id;&lt;br /&gt;    string _firstName;&lt;br /&gt;    string _lastName;&lt;br /&gt;&lt;br /&gt;    public int ID&lt;br /&gt;    {&lt;br /&gt;        get{return _id;}&lt;br /&gt;        set{_id = value;}&lt;br /&gt;    }&lt;br /&gt;    public string FirstName&lt;br /&gt;    {&lt;br /&gt;        get{return _firstName;}&lt;br /&gt;        set{_firstName = value;}&lt;br /&gt;    }&lt;br /&gt;    public string LastName&lt;br /&gt;    {&lt;br /&gt;        get{return _lastName;}&lt;br /&gt;        set{_lastName = value;}&lt;br /&gt;    }&lt;br /&gt;    public string FullName&lt;br /&gt;    {&lt;br /&gt;        get{return FirstName + " " + LastName;}&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; As you can see from the above class declaration, it doesn't contain any additional logic. The get and set properties are repetitive and they simply set or get the values of the properties without adding any value. In C#, you can simplify that by leveraging the new feature named Auto-Implemented properties. By taking advantage of this new feature, you can rewrite the above code as follows: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; public class Person&lt;br /&gt;{&lt;br /&gt;    public int ID { get; set; }&lt;br /&gt;    public string FirstName { get; set; }&lt;br /&gt;    public string LastName { get; set; }&lt;br /&gt;    public string FullName&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return FirstName + " " + LastName;&lt;br /&gt;        }&lt;br /&gt;        private set {;}&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; In the above code, when you declare a property, the compiler automatically creates a private, anonymous field that is available only to the property's get and set accessors. Note that the auto implemented properties must declare both a get and set accessor. However if you need to create a read-only property, modify the scope of the set accessor to be private.  &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Object Initializers&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In previous versions of C#, you would create the object in one step and then populate its properties in a separate next step. However with C# 3.0, you can create the object as well as set its properties in a single line of code. For example, consider the following lines of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; Person obj = new Person();&lt;br /&gt;obj.ID = 1;&lt;br /&gt;obj.FirstName = "Thiru";&lt;br /&gt;obj.LastName = "Thangarathinam";&lt;br /&gt;MessageBox.Show(obj.FullName); &lt;/code&gt;&lt;/p&gt; &lt;p&gt; In the above code, you create the Person object and set its properties appropriate values. By leveraging the object initializers feature, you can simplify the above code as follows: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; Person obj = new Person { ID = 1, FirstName = "Thiru", LastName = "Thangarathinam" };&lt;br /&gt;MessageBox.Show(obj.FullName); &lt;/code&gt;&lt;/p&gt; &lt;p&gt; In the above code lines of code, you directly assign the values to the properties of the Person object. Although you can simulate this behavior using constructor for the object, object initializers reduce the need to have a specific constructor for every variation of argument variation we need over time. &lt;/p&gt; &lt;p&gt; This becomes all the more important in cases where you need to write LINQ based select projection queries which transform and create a new object for the results of the query.  &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Collection Initializers&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In C# 2.0, when you want to populate a collection, you need to write the following line of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; List&lt;string&gt; names = new List&lt;string&gt;();&lt;br /&gt;names.Add("David");&lt;br /&gt;names.Add("Tim");&lt;br /&gt;names.Add("Doug"); &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Now with the introduction of the new collection initializers feature in C# 3.0, you can shorten the above lines of code to a single line of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; List&lt;string&gt; names = new List&lt;string&gt; {"David", "Tim", "Doug"}; &lt;/code&gt;&lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Anonymous Types&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; As the name suggests, anonymous types allow you to create a type on-the-fly at compile time. The newly created type has public properties and backing fields defined for the members you initialize during construction. For example, consider the following line of code: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; var obj=new{ID=1,FirstName="Thiru",LastName="Thangarathinam"}; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; In the above line, you just specify the various attributes you want to have in the anonymous class and assign the instantiated object to a variable of type "var". The actual type assigned to obj is determined by the compiler. Since the compiler assigns the name of the type only at compile time, you can't pass an anonymous type to another method and it can only be used within the method they were declared. &lt;/p&gt; &lt;p&gt; When the compiler sees the above code, it automatically declares a class as follows: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; class __Anonymous1&lt;br /&gt;{&lt;br /&gt;    private int _id = 1;&lt;br /&gt;    private string _firstName = "Thiru";&lt;br /&gt;    private string _lastName = "Thangarathinam";&lt;br /&gt;&lt;br /&gt;    public int ID&lt;br /&gt;    {&lt;br /&gt;        get{return _id;}&lt;br /&gt;        set{_id = value;}&lt;br /&gt;    }&lt;br /&gt;    public string FirstName&lt;br /&gt;    {&lt;br /&gt;        get{return _firstName;}&lt;br /&gt;        set{_firstName = value;}&lt;br /&gt;    }&lt;br /&gt;    public string LastName&lt;br /&gt;    {&lt;br /&gt;        get{return _lastName;}&lt;br /&gt;        set{_lastName = value;}&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Anonymous Types use the Object Initializer to specify what properties the new type will be declare. This allows us to reduce code looking similar to this: &lt;/p&gt; &lt;p&gt; Note that the anonymous types are just meant to be placeholders for quickly defining entity types and you can't add methods or customize the behavior of an anonymous type. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Extension Methods&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Another important feature introduced with C# is the ability to add new static methods to existing classes, known as extension methods. Using this new feature, you can extend the built-in classes (such as the String class) to support your custom requirements. For example, you can add a new method named "IsValidZipCode" to the string class that validates the zip code format. Let us discuss the code required to accomplish this: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; namespace StringExtensions&lt;br /&gt;{&lt;br /&gt;    public static class CustomStringExtension&lt;br /&gt;    {&lt;br /&gt;        public static bool IsValidZipCode(this string input)&lt;br /&gt;        {&lt;br /&gt;            Regex regEx = new Regex(@"^\d{5}$");&lt;br /&gt;            return regEx.IsMatch(input);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; As part of the declaring the arguments for the IsValidZipCode, you specify the name of the type to which the extension method should be added as the first parameter. In this case, since we want the IsValidZipCode method to be added to the string class, you specify string as the first parameter. Once you are inside the IsValidZipCode() method, you can access all of the public properties/methods/events of the actual string instance that the method is being called on. In this example, you return true or false depending on whether it is a valid zip code or not. &lt;/p&gt; &lt;p&gt; Now that you have implemented the extension method, the next step is to invoke it from the client application. To be able to do that, you first need to import the namespace in which the CustomStringExtension is located. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; using StringExtensions; &lt;/code&gt;&lt;/p&gt; &lt;p&gt; Once you have imported the namespace, the next step is to declare a variable of type string and invoke the IsValidZipCode() method. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; private void btnTestExtensionMethod_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    string zip = "85226";&lt;br /&gt;    if (zip.IsValidZipCode())&lt;br /&gt;        MessageBox.Show("Valid Zipcode format");&lt;br /&gt;    else&lt;br /&gt;        MessageBox.Show("Invalid Zipcode format");&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; As you can see from the preceding lines of code, the extension methods allow you to write cleaner and easy-to-maintain code. &lt;/p&gt; &lt;p&gt; Here are some of the key characteristics of extension methods: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;The extension method as well as the class that contains the extension method should be static.&lt;/li&gt;&lt;li&gt;Although extension methods are static methods, they are invoked as if they are instance methods.&lt;/li&gt;&lt;li&gt;The first parameter passed to the extension method specifies the type on which they operate and it is preceded by the "this" keyword.&lt;/li&gt;&lt;li&gt;From within the extension method, you can't access the private variables of the type you are extending.&lt;/li&gt;&lt;li&gt;Instance methods take precedence over extension methods in situations where they have same signature.&lt;/li&gt;&lt;/ul&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Lambda Expressions&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; Anonymous methods is a new feature introduced with C# 2.0 that enables you to declare your method code inline instead of with a delegate function. Let us take a look at a simple anonymous method: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; public Forms()&lt;br /&gt;{&lt;br /&gt;    check = new CheckBox(...);&lt;br /&gt;    text  = new TextBox(...);&lt;br /&gt;    checkBox.CheckedChanged += delegate&lt;br /&gt;    {&lt;br /&gt;        text.Text = "...";&lt;br /&gt;    };&lt;br /&gt;} &lt;/code&gt;&lt;/p&gt; &lt;p&gt; As you can see in the above code, you don't have to explicitly declare a new method to link it with an event. C# 3.0 introduces an even simpler syntax, lambda expressions, which you write as a parameter list followed by the "=&gt;" token, followed by an expression or a statement block. &lt;/p&gt; &lt;p&gt; Lambda expressions are simply functions and they are declared in the context of expressions than as a member of a class. It is an inline expression or a statement block which can be used to pass arguments to a method or assign value to delegate. All lambda expressions use the lambda operator =&gt; and the left side of the operator denotes the results and the right side contains the expression to be evaluated. For instance, consider the following lambda expression: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; age =&gt; age + 1 &lt;/code&gt;&lt;/p&gt; &lt;p&gt; The above function takes one argument named age, and returns age + 1 as the result. As you can see, Lambda expressions follow the below syntax: &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; (parameter-list) =&gt; expression;  &lt;/code&gt;&lt;/p&gt; &lt;p&gt; where expression can be any C# expression or a block of code. Just like anonymous methods you can use a lambda expression in place of a delegate. Here are some sample lambda expressions and their corresponding delegates. &lt;/p&gt; &lt;p style=""&gt;&lt;code&gt; //Explicitly typed parameter&lt;br /&gt;(Person obj) =&gt; MessageBox.Show(obj.FirstName.ToUpper());&lt;br /&gt;&lt;br /&gt;//Implicitly typed parameter&lt;br /&gt;(obj) =&gt; obj.FirstName == "Thiru";&lt;br /&gt;&lt;br /&gt;//Explicitly typed parameter&lt;br /&gt;(int a, int b) =&gt; a + b&lt;br /&gt;&lt;br /&gt;//Implicitly typed parameter&lt;br /&gt; (x, y) =&gt; { return x + y; } &lt;/code&gt;&lt;/p&gt; &lt;p&gt; As you see from the preceding lines of code, lambda expressions can be written in such a way that it can infer the parameter type from the signature of the delegate it is assigned to. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;     &lt;span class="clsTitle"&gt;Conclusion&lt;/span&gt;     &lt;/p&gt;&lt;p&gt;&lt;span class="clsBlurb"&gt;&lt;p&gt; In this article, you have understood the object oriented features introduced with C# 3.0. Specifically, &lt;/p&gt; &lt;ul&gt;&lt;li&gt;How to use auto-implemented properties for creating placeholder classes&lt;/li&gt;&lt;li&gt;How to initialize object and collections using a simple, intuitive syntax&lt;/li&gt;&lt;li&gt;How to extend built-in classes using extension methods&lt;/li&gt;&lt;li&gt;How to use anonymous types for creating classes on-the-fly&lt;/li&gt;&lt;li&gt;How to use Lambda expressions to declare method inline&lt;/li&gt;&lt;/ul&gt; &lt;p&gt; As you can see, the new features of C# make the development of .NET applications a breezy experience by reducing the number of lines of code to perform common operations such as initializing an object&lt;!--,  or initializing an object and so on--&gt;. &lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6253127828287264285?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6253127828287264285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6253127828287264285'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/new-object-oriented-features-in-c-30.html' title='New Object Oriented Features in C# 3.0'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-1347395657988422159</id><published>2010-01-19T01:52:00.000-08:00</published><updated>2010-01-19T02:17:12.749-08:00</updated><title type='text'>ASP.NET Interview Questions</title><content type='html'>&lt;div  style="text-align: center;font-family:arial;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 153, 0);font-size:100%;" &gt;ASP.NET Interview Questions&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;This is a list of questions I have gathered and created over a period of time from my experience, many of which I felt where incomplete or simply wrong।  I have finally taken the time to go through each question and correct them to the best of my ability.  However, please feel free to post feedback to challenge, improve, or suggest new questions.  I want to thank those of you that have contributed quality questions and corrections thus far.&lt;br /&gt;&lt;br /&gt;There are some questions in this list that I do not consider to be good questions for an interview।  However, they do exist on other lists available on the Internet so I felt compelled to keep them here for easy access.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1&lt;/span&gt;. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.&lt;br /&gt;inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.&lt;/span&gt; What’s the difference between Response.Write() andResponse.Output.Write()?&lt;br /&gt;Response.Output.Write() allows you to write formatted output.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt; What methods are fired during the page load?&lt;br /&gt;Init() - when the page is instantiated&lt;br /&gt;Load() - when the page is loaded into server memory&lt;br /&gt;PreRender() - the brief moment before the page is displayed to the user as HTML&lt;br /&gt;Unload() - when page finishes loading.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. &lt;/span&gt;When during the page processing cycle is ViewState available?&lt;br /&gt;After the Init() and before the Page_Load(), or OnLoad() for a control.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. &lt;/span&gt;What namespace does the Web page belong in the .NET Framework class hierarchy?&lt;br /&gt;System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.&lt;/span&gt; Where do you store the information about the user’s locale?&lt;br /&gt;System.Web.UI.Page.Culture&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.&lt;/span&gt; What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?&lt;br /&gt;CodeBehind is relevant to Visual Studio.NET only.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8. &lt;/span&gt;What’s a bubbled event?&lt;br /&gt;When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9. &lt;/span&gt;Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.  Where do you add an event handler?&lt;br /&gt;Add an OnMouseOver attribute to the button.  Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10.&lt;/span&gt; What data types do the RangeValidator control support?&lt;br /&gt;Integer, String, and Date.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11.&lt;/span&gt; Explain the differences between Server-side and Client-side code?&lt;br /&gt;Server-side code executes on the server.  Client-side code executes in the client's browser.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;12.&lt;/span&gt; What type of code (server or client) is found in a Code-Behind class?&lt;br /&gt;The answer is server-side code since code-behind is executed on the server.  However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser.  But just to be clear, code-behind executes on the server, thus making it server-side code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;13. &lt;/span&gt;Should user input data validation occur server-side or client-side?  Why?&lt;br /&gt;All user input data validation should occur on the server at a minimum.  Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;14.&lt;/span&gt; What is the difference between Server.Transfer and Response.Redirect?  Why would I choose one over the other?&lt;br /&gt;Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser.  This provides a faster response with a little less overhead on the server.  Server.Transfer does not update the clients url history list or current url.  Response.Redirect is used to redirect the user's browser to another page or site.  This performas a trip back to the client where the client's browser is redirected to the new page.  The user's browser history list is updated to reflect the new address.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;15.&lt;/span&gt; Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?&lt;br /&gt;Valid answers are:&lt;br /&gt;·  A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.&lt;br /&gt;·  A DataSet is designed to work without any continuing connection to the original data source.&lt;br /&gt;·  Data in a DataSet is bulk-loaded, rather than being loaded on demand.&lt;br /&gt;·  There's no concept of cursor types in a DataSet.&lt;br /&gt;·  DataSets have no current record pointer You can use For Each loops to move through the data.&lt;br /&gt;·  You can store many edits in a DataSet, and write them to the original data source in a single operation.&lt;br /&gt;·  Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;16.&lt;/span&gt; What is the Global.asax used for?&lt;br /&gt;The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;17. &lt;/span&gt;What are the Application_Start and Session_Start subroutines used for?&lt;br /&gt;This is where you can set the specific variables for the Application and Session objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;18.&lt;/span&gt; Can you explain what inheritance is and an example of when you might use it?&lt;br /&gt;When you want to inherit (use the functionality of) another class.  Example: With a base class named Employee, a Manager class could be derived from the Employee base class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;19. &lt;/span&gt;Whats an assembly?&lt;br /&gt;Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;20.&lt;/span&gt; Describe the difference between inline and code behind.&lt;br /&gt;Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;21.&lt;/span&gt; Explain what a diffgram is, and a good use for one?&lt;br /&gt;The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML.  A good use is reading database data to an XML file to be sent to a Web Service.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;22.&lt;/span&gt; Whats MSIL, and why should my developers need an appreciation of it if at all?&lt;br /&gt;MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.  MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;23. &lt;/span&gt;Which method do you invoke on the DataAdapter control to load your generated dataset with data?&lt;br /&gt;The Fill() method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;24. &lt;/span&gt;Can you edit data in the Repeater control?&lt;br /&gt;No, it just reads the information from its data source.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;25. &lt;/span&gt;Which template must you provide, in order to display data in a Repeater control?&lt;br /&gt;ItemTemplate.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;26.&lt;/span&gt; How can you provide an alternating color scheme in a Repeater control?&lt;br /&gt;Use the AlternatingItemTemplate.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;27.&lt;/span&gt; What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?&lt;br /&gt;You must set the DataSource property and call the DataBind method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;28.&lt;/span&gt; What base class do all Web Forms inherit from?&lt;br /&gt;The Page class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;29.&lt;/span&gt; Name two properties common in every validation control?&lt;br /&gt;ControlToValidate property and Text property.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;30. &lt;/span&gt;Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?&lt;br /&gt;DataTextField property.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;31. &lt;/span&gt;Which control would you use if you needed to make sure the values in two different controls matched?&lt;br /&gt;CompareValidator control.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;32.&lt;/span&gt; How many classes can a single .NET DLL contain?&lt;br /&gt;It can contain many classes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;Web Service&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. &lt;/span&gt;What is the transport protocol you use to call a Web service?&lt;br /&gt;SOAP (Simple Object Access Protocol) is the preferred protocol.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. &lt;/span&gt;True or False: A Web service can only be written in .NET?&lt;br /&gt;False&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt; What does WSDL stand for?&lt;br /&gt;Web Services Description Language.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. &lt;/span&gt;Where on the Internet would you look for Web services?&lt;br /&gt;http://www.uddi.org&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.&lt;/span&gt; True or False: To test a Web service you must create a Windows application or Web application to consume this service?&lt;br /&gt;False, the web service comes with a test page and it provides HTTP-GET method to test.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;State Management&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.&lt;/span&gt; What is ViewState?&lt;br /&gt;ViewState allows the state of objects (serializable) to be stored in a hidden field on the page.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.  ViewState is used the retain the state of server-side objects between postabacks.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.&lt;/span&gt; What is the lifespan for items stored in ViewState?&lt;br /&gt;Item stored in ViewState exist for the life of the current page.  This includes postbacks (to the same page).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt; What does the "EnableViewState" property do?  Why would I want it on or off?&lt;br /&gt;It allows the page to save the users input on a form across postbacks.  It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser.  When the page is posted back to the server the server control is recreated with the state stored in viewstate.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.&lt;/span&gt; What are the different types of Session state management options available with ASP.NET?&lt;br /&gt;ASP।NET provides In-Process and Out-of-Process state management.  In-Process stores the session in memory on the web server.  This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server.  Out-of-Process Session state management stores data in an external data source.  The external data source may be either a SQL Server or a State Server service.  Out-of-Process state management requires that all objects stored in session are serializable.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 153, 102);"&gt;its also important asp.net  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. What are the main differences between asp and asp.net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ASP 3.0&lt;br /&gt;&lt;br /&gt;• Supports VBScript and JavaScript&lt;br /&gt;o scripting languages are limited in scope&lt;br /&gt;o interpreted from top to bottom each time the page is loaded&lt;br /&gt;• Files end with *.asp extension&lt;br /&gt;• 5 objects: Request, Response, Server, Application, Session&lt;br /&gt;• Queried databases return recordsets&lt;br /&gt;• Uses conventional HTML forms for data collection&lt;br /&gt;&lt;br /&gt;ASP .NET&lt;br /&gt;&lt;br /&gt;• Supports a number of languages including Visual Basic, C#, and JScript&lt;br /&gt;o code is compiled into .NET classes and stored to speed up multiple hits on a page&lt;br /&gt;o object oriented and event driven makes coding web pages more like traditional applications&lt;br /&gt;• Files end with *.aspx extension&lt;br /&gt;• .NET contains over 3400 classes&lt;br /&gt;• XML-friendly data sets are used instead of recordsets&lt;br /&gt;• Uses web forms that look like HTML forms to the client, but add much functionality due to server-side coding&lt;br /&gt;• Has built-in validation objects&lt;br /&gt;• Improved debugging feature (great news for programmers)&lt;br /&gt;• ASP .NET controls can be binded to a data source, including XML recordsets&lt;br /&gt;Source: mikekissman.com&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. What is a user control?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;• An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience).&lt;br /&gt;Source: 15seconds.com&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. What are different types of controls available in ASP.net?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;• HTML server controls HTML elements exposed to the server so you can program them. HTML server controls expose an object model that maps very closely to the HTML elements that they render.&lt;br /&gt;• Web server controls Controls with more built-in features than HTML server controls. Web server controls include not only form-type controls such as buttons and text boxes, but also special-purpose controls such as a calendar. Web server controls are more abstract than HTML server controls in that their object model does not necessarily reflect HTML syntax.&lt;br /&gt;• Validation controls Controls that incorporate logic to allow you to test a user's input. You attach a validation control to an input control to test what the user enters for that input control. Validation controls are provided to allow you to check for a required field, to test against a specific value or pattern of characters, to verify that a value lies within a range, and so on.&lt;br /&gt;• User controls Controls that you create as Web Forms pages. You can embed Web Forms user controls in other Web Forms pages, which is an easy way to create menus, toolbars, and other reusable elements.&lt;br /&gt;• Note You can also create output for mobile devices. To do so, you use the same ASP.NET page framework, but you create Mobile Web Forms instead of Web Forms pages and use controls specifically designed for mobile devices.&lt;br /&gt;Source: MSDN&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. What are the validation controls available in ASP.net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Type of validation Control to use&lt;br /&gt;Description&lt;br /&gt;&lt;br /&gt;Required entry RequiredFieldValidator Ensures that the user does not skip an entry.&lt;br /&gt;Comparison to a value CompareValidator Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).&lt;br /&gt;Range checking RangeValidator Checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.&lt;br /&gt;Pattern matching RegularExpressionValidator Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.&lt;br /&gt;User-defined CustomValidator Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.&lt;br /&gt;Source: MSDN&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. How will you upload a file to IIS in Asp and how will you do the same in ASP.net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old &lt;input with="" the="" set="" to="" such="" as="" type=""&gt;&lt;input id="”myFile”" runat="server" type="file"&gt;.&lt;br /&gt;This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;myFile.PostedFile.SaveAs ("DestinationPath")&lt;br /&gt;&lt;br /&gt;Note: The Form should have the following ENC Type&lt;br /&gt;&lt;/span&gt;&lt;form style="font-family: arial;" enctype="multipart/form-data" runat="server"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;Source: ASP Alliance&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6. What is Attribute Programming? What are attributes? Where are they used?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.&lt;br /&gt;Source: OnDotNet.com&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7. What is the difference between Data Reader &amp;amp; Dataset?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Data Reader is connected, read only forward only record set.&lt;br /&gt;Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8. What is the difference between server side and client side code?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Server code is executed on the web server where as the client code is executed on the browser machine.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9. Why would you use “EnableViewState” property? What are the disadvantages?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;EnableViewState allows me to retain the values of the controls properties across the requests in the same session. It hampers the performance of the application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10. What is the difference between Server. Transfer and Response. Redirect?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Transfer method allows you to transfer from inside one ASP page to another ASP page. All of the state information that has been created for the first (calling) ASP page will be transferred to the second (called) ASP page. This transferred information includes all objects and variables that have been given a value in an Application or Session scope, and all items in the Request collections. For example, the second ASP page will have the same SessionID as the first ASP page.&lt;br /&gt;&lt;br /&gt;When the second (called) ASP page completes its tasks, you do not return to the first (calling) ASP page. All these happen on the server side browser is not aware of this.&lt;br /&gt;The redirect message issue HTTP 304 to the browser and causes browser to got the specified page. Hence there is round trip between client and server. Unlike transfer, redirect doesn’t pass context information to the called page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11. What is the difference between Application_start and Session_start?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Application_start gets fired when an application receive the very first request.&lt;br /&gt;Session_start gets fired for each of the user session.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;12. What is inheritance and when would you use inheritance?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The concept of child class inheriting the behavior of the parent is called inheritance.&lt;br /&gt;If there are many classes in an application that have some part of their behavior common among all , inheritance would be used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;13. What is the order of events in a web form?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Init&lt;br /&gt;2. Load&lt;br /&gt;3. Cached post back events&lt;br /&gt;4. Prerender&lt;br /&gt;5. Unload&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;14. Can you edit Data in repeater control?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;15. Which template you must provide to display data in a repeater control?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Item Template&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;16. How can you provide an alternating color scheme in a Data Grid?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use ALTERNATINGITEMSTYLE and ITEMSTYLE, attributes or Templates&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;17. Is it possible to bind a data to Textbox?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;18. What method I should call to bind data to control?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bind Data ()&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;19. How can I kill a user session?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Call session. abandon.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;21. Which is the common property among all the validation controls?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ControlToValidate&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;22. How do you bind a data grid column manually?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use BoundColumn tag.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;23. Web services can only be written in .NET, true or false?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;False&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;24. What does WSDL, UDDI stands for?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Web Service Description Language.&lt;br /&gt;Universal Description Discovery and Integration&lt;br /&gt;25. How can you make a property read only? (C#)&lt;br /&gt;&lt;br /&gt;Use key word Read Only&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;25. Which validation control is used to match values in two controls?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Compare Validation control.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;26. To test a Web Service I must create either web application or windows application. True or false?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;False&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;27. How many classes can a single .NET assembly contains?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Any number&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;28. What are the data types available in JavaScript?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Object is the only data type available.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;29. Is it possible to share session information among ASP and ASPX page?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No, it is not possible as both of these are running under different processes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;30. What are the caching techniques available?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Page cahahing.&lt;br /&gt;Fragment Caching&lt;br /&gt;And Data Caching&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;31. What are the different types of authentication modes available?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Window.&lt;br /&gt;2. Form.&lt;br /&gt;3. Passport.&lt;br /&gt;4. None.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;32. Explain the steps involved to populate dataset with data?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Open connection&lt;br /&gt;Initialize Adapter passing SQL and connection as parameter&lt;br /&gt;Initialize Dataset&lt;br /&gt;Call Fill method of the adapter passes dataset as the parameter&lt;br /&gt;Close connection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;33. Can I have data from two different sources into a single dataset?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes, it is possible.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;34. Is it possible load XML into a Data Reader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;35. Is it possible to have tables in the dataset that are not bound to any data source?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes, we can create table object in code and add it to the dataset.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;36. Why do you deploy an assembly into GAC?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To allow other application to access the shared assembly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;37. How do you uninstall assembly from GAC?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use Gacutil.exe with U switch.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;38. What does Regasm do?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Once a class is registered, any COM client can use it as though the class were a COM class. The class is registered only once, when the assembly is installed. Instances of classes within the assembly cannot be created from COM until they are actually registered.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;39. What is the difference between Execute Scalar and ExceuteNoneQuery?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Execute Scalar returns the value in the first row first column of a query result set.&lt;br /&gt;ExceuteNonQuery return number of rows affected.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;40. What is an assembly?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assembly is a deployment unit of .NET application. In practical terms assembly is an Executable or a class library.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;41. What is CLR?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The common language runtime is the execution engine for .NET Framework applications.&lt;br /&gt;It provides a number of services, including the following:&lt;br /&gt;• Code management (loading and execution)&lt;br /&gt;Application memory isolation&lt;br /&gt;• Verification of type safety&lt;br /&gt;• Conversion of IL to native code&lt;br /&gt;• Access to metadata (enhanced type information)&lt;br /&gt;• Managing memory for managed objects&lt;br /&gt;• Enforcement of code access security&lt;br /&gt;• Exception handling, including cross-language exceptions&lt;br /&gt;• Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)&lt;br /&gt;• Automation of object layout&lt;br /&gt;• Support for developer services (profiling, debugging, and so on)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;42. What is the common type system (CTS)?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The common type system is a rich type system, built into the common language runtime that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;43. What is the Common Language Specification (CLS)?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs following the rules of the CLS, those APIs are easily used from all other programming languages that target the common language runtime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;44. What is the Microsoft Intermediate Language (MSIL)?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.&lt;br /&gt;Combined with metadata and the common type system, MSIL allows for true cross-language integration.&lt;br /&gt;Prior to execution, MSIL is converted to machine code. It is not interpreted.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;45. What is managed code and managed data?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Managed code is code that is written to target the services of the common language runtime (see what is the Common Language Runtime?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR).&lt;br /&gt;Closely related to managed code is managed data—data that is allocated and de-allocated by the common language runtime's garbage collector. C#, Visual Basic, and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;46. What is an assembly?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit or as accessible by code outside that unit.&lt;br /&gt;&lt;br /&gt;Assemblies are self-describing by means of their manifest, which is an integral part of every assembly.&lt;br /&gt;&lt;br /&gt;The manifest: Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications).&lt;br /&gt;Defines what files (by name and file hash) make up the assembly implementation.&lt;br /&gt;Specifies the types and resources that make up the assembly, including which are exported from the assembly.&lt;br /&gt;Itemizes the compile-time dependencies on other assemblies.&lt;br /&gt;Specifies the set of permissions required for the assembly to run properly.&lt;br /&gt;&lt;br /&gt;This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for any running object, since every type is loaded in the context of an assembly. Assemblies are also the unit at which code access security permissions are applied. The identity evidence for each assembly is considered separately when determining what permissions to grant the code it contains.&lt;br /&gt;The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;47. What are private assemblies and shared assemblies?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein). A shared assembly is one that can be referenced by more than one application. In order to share an assembly, the assembly must be explicitly built for this purpose by giving it a cryptographically strong name (referred to as a strong name). By contrast, a private assembly name need only be unique within the application that uses it.&lt;br /&gt;By making a distinction between private and shared assemblies, we introduce the notion of sharing as an explicit decision. Simply by deploying private assemblies to an application directory, you can guarantee that that application will run only with the bits it was built and deployed with. References to private assemblies will only be resolved locally to the private application directory.&lt;br /&gt;There are several reasons you may elect to build and use shared assemblies, such as the ability to express version policy. The fact that shared assemblies have a cryptographically strong name means that only the author of the assembly has the key to produce a new version of that assembly. Thus, if you make a policy statement that says you want to accept a new version of an assembly, you can have some confidence that version updates will be controlled and verified by the author. Otherwise, you don't have to accept them.&lt;br /&gt;For locally installed applications, a shared assembly is typically explicitly installed into the global assembly cache (a local cache of assemblies maintained by the .NET Framework). Key to the version management features of the .NET Framework is that downloaded code does not affect the execution of locally installed applications. Downloaded code is put in a special download cache and is not globally available on the machine even if some of the downloaded components are built as shared assemblies.&lt;br /&gt;The classes that ship with the .NET Framework are all built as shared assemblies.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;48. If I want to build a shared assembly, does that require the overhead of signing and managing key pairs?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name).&lt;br /&gt;Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;49. What is the difference between a namespace and an assembly name?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under the control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the Microsoft® ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;50. What options are available to deploy my .NET applications?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The .NET Framework simplifies deployment by making zero-impact install and XCOPY deployment of applications feasible. Because all requests are resolved first to the private application directory, simply copying an application's directory files to disk is all that is needed to run the application. No registration is required.&lt;br /&gt;This scenario is particularly compelling for Web applications, Web Services, and self-contained desktop applications. However, there are scenarios where XCOPY is not sufficient as a distribution mechanism. An example is when the application has little private code and relies on the availability of shared assemblies, or when the application is not locally installed (but rather downloaded on demand). For these cases, the .NET Framework provides extensive code download services and integration with the Windows Installer. The code download support provided by the .NET Framework offers several advantages over current platforms, including incremental download, code access security (no more Authenticode dialogs), and application isolation (code downloaded on behalf of one application doesn't affect other applications). The Windows Installer is another powerful deployment mechanism available to .NET applications. All of the features of Windows Installer, including publishing, advertisement, and application repair will be available to .NET applications in Windows Installer 2.0.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;51. I've written an assembly that I want to use in more than one application. Where do I deploy it?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assemblies that are to be used by multiple applications (for example, shared assemblies) are deployed to the global assembly cache. In the prerelease and Beta builds, use the /i option to the GACUtil SDK tool to install an assembly into the cache:&lt;br /&gt;gacutil /i myDll.dll&lt;br /&gt;Windows Installer 2.0, which ships with Windows XP and Visual Studio .NET will be able to install assemblies into the global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;52. How can I see what assemblies are installed in the global assembly cache?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;53. What is an application domain?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.&lt;br /&gt;&lt;br /&gt;An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;54. What is garbage collection?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;55. How does non-deterministic garbage collection affect my code?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;56. Can I avoid using the garbage collected heap?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All languages that target the runtime allow you to allocate class objects from the garbage-collected heap. This brings benefits in terms of fast allocation, and avoids the need for programmers to work out when they should explicitly 'free' each object.&lt;br /&gt;The CLR also provides what are called ValueTypes—these are like classes, except that ValueType objects are allocated on the runtime stack (rather than the heap), and therefore reclaimed automatically when your code exits the procedure in which they are defined. This is how "structs" in C# operate.&lt;br /&gt;Managed Extensions to C++ lets you choose where class objects are allocated. If declared as managed Classes, with the __gc keyword, then they are allocated from the garbage-collected heap. If they don't include the __gc keyword, they behave like regular C++ objects, allocated from the C++ heap, and freed explicitly with the "free" method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;57. How do in-process and cross-process communication work in the Common Language Runtime?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two aspects to in-process communication: between contexts within a single application domain, or across application domains. Between contexts in the same application domain, proxies are used as an interception mechanism. No marshaling/serialization is involved. When crossing application domains, we do marshaling/serialization using the runtime binary protocol.&lt;br /&gt;Cross-process communication uses a pluggable channel and formatter protocol, each suited to a specific purpose.&lt;br /&gt;If the developer specifies an endpoint using the tool soapsuds.exe to generate a metadata proxy, HTTP channel with SOAP formatter is the default.&lt;br /&gt;If a developer is doing explicit remoting in the managed world, it is necessary to be explicit about what channel and formatter to use. This may be expressed administratively, through configuration files, or with API calls to load specific channels. Options are:&lt;br /&gt;HTTP channel w/ SOAP formatter (HTTP works well on the Internet, or anytime traffic must travel through firewalls)&lt;br /&gt;TCP channel w/ binary formatter (TCP is a higher performance option for local-area networks (LANs))&lt;br /&gt;When making transitions between managed and unmanaged code, the COM infrastructure (specifically, DCOM) is used for remoting. In interim releases of the CLR, this applies also to serviced components (components that use COM+ services). Upon final release, it should be possible to configure any remotable component.&lt;br /&gt;Distributed garbage collection of objects is managed by a system called "leased based lifetime." Each object has a lease time, and when that time expires, the object is disconnected from the remoting infrastructure of the CLR. Objects have a default renew time-the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;58. Can I use COM objects from a .NET Framework program?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Yes. Any COM component you have deployed today can be used from managed code, and in common cases the adaptation is totally automatic.&lt;br /&gt;Specifically, COM components are accessed from the .NET Framework by use of a runtime callable wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET Framework-compatible interfaces. For OLE automation interfaces, the RCW can be generated automatically from a type library. For non-OLE automation interfaces, a developer may write a custom RCW and manually map the types exposed by the COM interface to .NET Framework-compatible types.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;59. Can .NET Framework components be used from a COM program?&lt;br /&gt;&lt;br /&gt;Yes. Managed types you build today can be made accessible from COM, and in the common case the configuration is totally automatic. There are certain new features of the managed development environment that are not accessible from COM. For example, static methods and parameterized constructors cannot be used from COM. In general, it is a good idea to decide in advance who the intended user of a given type will be. If the type is to be used from COM, you may be restricted to using those features that are COM accessible.&lt;br /&gt;Depending on the language used to write the managed type, it may or may not be visible by default.&lt;br /&gt;Specifically, .NET Framework components are accessed from COM by using a COM callable wrapper (CCW). This is similar to an RCW (see previous question), but works in the opposite direction. Again, if the .NET Framework development tools cannot automatically generate the wrapper, or if the automatic behavior is not what you want, a custom CCW can be developed.&lt;br /&gt;&lt;br /&gt;60. Can I use the Win32 API from a .NET Framework program?&lt;br /&gt;&lt;br /&gt;Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.&lt;br /&gt;Here is an example of C# calling the Win32 MessageBox function:&lt;br /&gt;using System;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;&lt;br /&gt;class MainApp&lt;br /&gt;{&lt;br /&gt;[DllImport("user32.dll", EntryPoint="MessageBox")]&lt;br /&gt;public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);&lt;br /&gt;&lt;br /&gt;public static void Main()&lt;br /&gt;{&lt;br /&gt;MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 );&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;61. What do I have to do to make my code work with the security system?&lt;br /&gt;&lt;br /&gt;Usually, not a thing—most applications will run safely and will not be exploitable by malicious attacks. By simply using the standard class libraries to access resources (like files) or perform protected operations (such as a reflection on private members of a type), security will be enforced by these libraries. The one simple thing application developers may want to do is include a permission request (a form of declarative security) to limit the permissions their code may receive (to only those it requires). This also ensures that if the code is allowed to run, it will do so with all the permissions it needs.&lt;br /&gt;Only developers writing new base class libraries that expose new kinds of resources need to work directly with the security system. Instead of all code being a potential security risk, code access security constrains this to a very small bit of code that explicitly overrides the security system.&lt;br /&gt;&lt;br /&gt;62. Why does my code get a security exception when I run it from a network shared drive?&lt;br /&gt;&lt;br /&gt;Default security policy gives only a restricted set of permissions to code that comes from the local intranet zone. This zone is defined by the Internet Explorer security settings, and should be configured to match the local network within an enterprise. Since files named by UNC or by a mapped drive (such as with the NET USE command) are being sent over this local network, they too are in the local intranet zone.&lt;br /&gt;The default is set for the worst case of an unsecured intranet. If your intranet is more secure you can modify security policy (with the .NET Framework Configuration tool or the CASPol tool) to grant more permissions to the local intranet, or to portions of it (such as specific machine share names).&lt;br /&gt;&lt;br /&gt;63. How do I make it so that code runs when the security system is stopping it?&lt;br /&gt;&lt;br /&gt;Security exceptions occur when code attempts to perform actions for which it has not been granted permission. Permissions are granted based on what is known about code; especially its location. For example, code run from the Internet is given fewer permissions than that run from the local machine because experience has proven that it is generally less reliable. So, to allow code to run that is failing due to security exceptions, you must increase the permissions granted to it. One simple way to do so is to move the code to a more trusted location (such as the local file system). But this won't work in all cases (web applications are a good example, and intranet applications on a corporate network are another). So, instead of changing the code's location, you can also change security policy to grant more permissions to that location. This is done using either the .NET Framework Configuration tool or the code access security policy utility (caspol.exe). If you are the code's developer or publisher, you may also digitally sign it and then modify security policy to grant more permissions to code bearing that signature. When taking any of these actions, however, remember that code is given fewer permissions because it is not from an identifiably trustworthy source—before you move code to your local machine or change security policy, you should be sure that you trust the code to not perform malicious or damaging actions.&lt;br /&gt;&lt;br /&gt;64. How do I administer security for my machine? For an enterprise?&lt;br /&gt;&lt;br /&gt;The .NET Framework includes the .NET Framework Configuration tool, an MMC snap-in (mscorcfg.msc), to configure several aspects of the CLR including security policy. The snap-in not only supports administering security policy on the local machine, but also creates enterprise policy deployment packages compatible with System Management Server and Group Policy. A command line utility, CASPol.exe, can also be used to script policy changes on the computer. In order to run either tool, in a command prompt, change the current directory to the installation directory of the .NET Framework (located in %windir%\Microsoft.Net\Framework\v1.0.2914.16\) and type mscorcfg.msc or caspol.exe.&lt;br /&gt;&lt;br /&gt;65. What’s the implicit name and type of the parameter that gets passed into the class’ set method?&lt;br /&gt;&lt;br /&gt;Value, and it’s data type depends on whatever variable we’re changing.&lt;br /&gt;&lt;br /&gt;66. How do you inherit from a class in C#?&lt;br /&gt;&lt;br /&gt;Place a colon and then the name of the base class. Notice that it’s double colon in C++.&lt;br /&gt;&lt;br /&gt;67. Does C# support multiple inheritance?&lt;br /&gt;&lt;br /&gt;No, use interfaces instead.&lt;br /&gt;&lt;br /&gt;68. When you inherit a protected class-level variable, who is it available to?&lt;br /&gt;&lt;br /&gt;Classes in the same namespace.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;69. Are private class-level variables inherited?&lt;br /&gt;&lt;br /&gt;Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.&lt;br /&gt;&lt;br /&gt;69. Describe the accessibility modifier protected internal.&lt;br /&gt;&lt;br /&gt;It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).&lt;br /&gt;&lt;br /&gt;70. C# provides a default constructor for me. I write a constructor that akes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?&lt;br /&gt;&lt;br /&gt;Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.&lt;br /&gt;&lt;br /&gt;71. What’s the top .NET class that everything is derived from?&lt;br /&gt;System.Object .&lt;br /&gt;&lt;br /&gt;72. How’s method overriding different from overloading?&lt;br /&gt;&lt;br /&gt;When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.&lt;br /&gt;&lt;br /&gt;73. What does the keyword virtual mean in the method definition?&lt;br /&gt;The method can be over-ridden.&lt;br /&gt;&lt;br /&gt;74. Can you declare the override method static while the original method is non-static?&lt;br /&gt;No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.&lt;br /&gt;&lt;br /&gt;75. Can you override private virtual methods?&lt;br /&gt;No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.&lt;br /&gt;&lt;br /&gt;76. Can you prevent your class from being inherited and becoming a base class for some other classes?&lt;br /&gt;&lt;br /&gt;Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.&lt;br /&gt;&lt;br /&gt;77. Can you allow class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;&lt;br /&gt;Yes, just leave the class public and make the method sealed.&lt;br /&gt;&lt;br /&gt;78. What’s an abstract class?&lt;br /&gt;&lt;br /&gt;A class that cannot be instantiated.A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.&lt;br /&gt;&lt;br /&gt;79. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?&lt;br /&gt;When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.&lt;br /&gt;&lt;br /&gt;80. What’s an interface class?&lt;br /&gt;It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.&lt;br /&gt;&lt;br /&gt;81. Why can’t you specify the accessibility modifier for methods inside the interface?&lt;br /&gt;They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.&lt;br /&gt;&lt;br /&gt;82. Can you inherit multiple interfaces?&lt;br /&gt;Yes, why not.&lt;br /&gt;&lt;br /&gt;83. And if they have conflicting method names?&lt;br /&gt;It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.&lt;br /&gt;&lt;br /&gt;84. What’s the difference between an interface and abstract class?&lt;br /&gt;In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.&lt;br /&gt;&lt;br /&gt;85. How can you overload a method?&lt;br /&gt;Different parameter data types, different number of parameters, different order of parameters.&lt;br /&gt;&lt;br /&gt;86. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?&lt;br /&gt;Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.&lt;br /&gt;&lt;br /&gt;87. What’s the difference between System. String and System.StringBuilder classes?&lt;br /&gt;System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed&lt;br /&gt;&lt;br /&gt;88. How big is the data type int in .NET?&lt;br /&gt;32 bits.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;89. How big is the char?&lt;br /&gt;16 bits (Unicode).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;90. How do you initiate a string without escaping each backslash?&lt;br /&gt;Put an @ sign in front of the double-quoted string.&lt;br /&gt;&lt;br /&gt;91. What are valid signatures for the Main function?&lt;br /&gt;public static void Main ()&lt;br /&gt;public static int Main ()&lt;br /&gt;public static void Main ( string[] args )&lt;br /&gt;public static int Main (string[] args )&lt;br /&gt;&lt;br /&gt;92. How do you initialize a two-dimensional array that you don’t know the dimensions of?&lt;br /&gt;int [ , ] myArray; //declaration&lt;br /&gt;myArray = new int [5, 8]; //actual initialization&lt;br /&gt;&lt;br /&gt;93. What’s the access level of the visibility type internal?&lt;br /&gt;Current application.&lt;br /&gt;&lt;br /&gt;94. What’s the difference between struct and class in C#?&lt;br /&gt;Structs cannot be inherited.&lt;br /&gt;Structs are passed by value, not by reference.&lt;br /&gt;Struct is stored on the stack, not the heap.&lt;br /&gt;&lt;br /&gt;95. Explain encapsulation.&lt;br /&gt;The implementation is hidden, the interface is exposed.&lt;br /&gt;&lt;br /&gt;96. What data type should you use if you want an 8-bit value that’s signed?&lt;br /&gt;sbyte .&lt;br /&gt;&lt;br /&gt;97. Speaking of Boolean data types, what’s different between C# and /C++?&lt;br /&gt;There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.&lt;br /&gt;&lt;br /&gt;98. Where are the value-type variables allocated in the computer RAM?&lt;br /&gt;Stack.&lt;br /&gt;&lt;br /&gt;99. Where do the reference-type variables go in the RAM?&lt;br /&gt;The references go on the stack, while the objects themselves go on the heap.&lt;br /&gt;&lt;br /&gt;100. What is the difference between the value-type variables and reference-type variables in terms of garbage collection?&lt;br /&gt;The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.&lt;br /&gt;&lt;br /&gt;101. How do you convert a string into an integer in .NET?&lt;br /&gt;Int32.Parse( string)&lt;br /&gt;&lt;br /&gt;102. How do you box a primitive data type variable?&lt;br /&gt;Assign it to the object, pass an object.&lt;br /&gt;&lt;br /&gt;103. Why do you need to box a primitive variable?&lt;br /&gt;&lt;br /&gt;To pass it by reference.&lt;br /&gt;&lt;br /&gt;104. What’s the difference between Java and .NET garbage collectors?&lt;br /&gt;&lt;br /&gt;Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.&lt;br /&gt;&lt;br /&gt;105. How do you enforce garbage collection in .NET?&lt;br /&gt;&lt;br /&gt;System.GC.Collect ( );&lt;br /&gt;&lt;br /&gt;106. Can you declare a C++ type destructor in C# like ~MyClass ()?&lt;br /&gt;&lt;br /&gt;Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.&lt;br /&gt;&lt;br /&gt;107. What’s different about namespace declaration when comparing that to package declaration in Java?&lt;br /&gt;&lt;br /&gt;No semicolon.&lt;br /&gt;&lt;br /&gt;108. What’s the difference between const and read only?&lt;br /&gt;&lt;br /&gt;You can initialize read only variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public read only string DateT = new DateTime ().ToString ().&lt;br /&gt;&lt;br /&gt;109. What does \a character do?&lt;br /&gt;&lt;br /&gt;On most systems, produces a rather annoying beep.&lt;br /&gt;&lt;br /&gt;110. Can you create enumerated data types in C#?&lt;br /&gt;&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;111. What’s different about switch statements in C#?&lt;br /&gt;&lt;br /&gt;No fall-throughs allowed.&lt;br /&gt;&lt;br /&gt;112. What happens when you encounter a continue statement inside the for loop?&lt;br /&gt;&lt;br /&gt;The code for the rest of the loop is ignored; the control is transferred back to the beginning of the loop.&lt;br /&gt;&lt;br /&gt;113. Is goto statement supported in C#? How about Java?&lt;br /&gt;&lt;br /&gt;Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/form&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-1347395657988422159?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1347395657988422159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1347395657988422159'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/aspnet-interview-questions.html' title='ASP.NET Interview Questions'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-126048132708033860</id><published>2010-01-19T01:37:00.000-08:00</published><updated>2010-01-19T01:38:39.490-08:00</updated><title type='text'>Using JavaScript to Display messages in ASP.NET pages</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Using JavaScript to Display messages in ASP.NET pages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;script language="javascript" src="script/ReasonForVisit.js"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;or in aspx page&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    function setmessage()&lt;br /&gt;    {&lt;br /&gt;    if(language=='english'){&lt;br /&gt;    document.getElementById('header1').innerHTML="No Records found.";&lt;br /&gt;    document.getElementById('span1').innerHTML="We are unable to find&lt;br /&gt;    your records.";&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    else{&lt;br /&gt;    document.getElementById('header1').innerHTML="No Records found.";&lt;br /&gt;    document.getElementById('span1').innerHTML="We are unable to find&lt;br /&gt;    your records.";&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;    .aspx pages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &gt;table style="width: 100%;" border="0" cellpadding="0" cellspacing="0" id="Table1"&gt;&lt;br /&gt;    &gt;tr align="center"&gt;&lt;br /&gt;    &gt;td id="header1"&gt;&lt;br /&gt;&lt;br /&gt;    /td&gt;&lt;br /&gt;    /tr&gt;&lt;br /&gt;    &gt;tr align="center"&gt;&lt;br /&gt;    &gt;td id="span1"&gt;&lt;br /&gt;&lt;br /&gt;    /td&gt;&lt;br /&gt;    /tr&gt;&lt;br /&gt;    /table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-126048132708033860?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/126048132708033860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/126048132708033860'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/using-javascript-to-display-messages-in.html' title='Using JavaScript to Display messages in ASP.NET pages'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-836190462589122288</id><published>2010-01-19T01:27:00.000-08:00</published><updated>2010-01-19T03:02:10.491-08:00</updated><title type='text'>ASP.NET: Calendar Control DayRender Sample Code</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_c2jrU6uj_ME/S1V8z2Ia0JI/AAAAAAAAAIY/hrkguuJMcxk/s1600-h/Calendar2.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 314px;" src="http://1.bp.blogspot.com/_c2jrU6uj_ME/S1V8z2Ia0JI/AAAAAAAAAIY/hrkguuJMcxk/s320/Calendar2.png" alt="" id="BLOGGER_PHOTO_ID_5428382156010999954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_c2jrU6uj_ME/S1V8zuAfNhI/AAAAAAAAAIQ/MiUXSSWOZqA/s1600-h/Calendar1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 312px;" src="http://1.bp.blogspot.com/_c2jrU6uj_ME/S1V8zuAfNhI/AAAAAAAAAIQ/MiUXSSWOZqA/s320/Calendar1.png" alt="" id="BLOGGER_PHOTO_ID_5428382153830250002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ASP.NET: Calendar Control DayRender Sample Code &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;.cs page&lt;/span&gt;&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;protected void Page_Load(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;OleDbConnection myConnection = new OleDbConnection(ConfigurationSettings.AppSettings["DBConnStr"]);&lt;br /&gt;string sql = "select eventid,eventdt,title1 from calendar";&lt;br /&gt;OleDbDataAdapter da = new OleDbDataAdapter(sql, myConnection);&lt;br /&gt;da.Fill(ds, "events");&lt;br /&gt;}&lt;br /&gt;protected void eventscalendar_DayRender(Object Src, DayRenderEventArgs E)&lt;br /&gt;{&lt;br /&gt;int i = 0;&lt;br /&gt;StringBuilder strEvents = new StringBuilder();&lt;br /&gt;strEvents.Append("");&lt;br /&gt;foreach (DataRow row in ds.Tables["events"].Rows)&lt;br /&gt;{&lt;br /&gt;DateTime eventdate = (DateTime)row["eventdt"];&lt;br /&gt;if (eventdate.Equals(E.Day.Date))&lt;br /&gt;{&lt;br /&gt;i++;&lt;br /&gt;strEvents.Append("&lt;br /&gt;" + row["title1"]);&lt;br /&gt;strEvents.Append("");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if (i &gt; 0)&lt;br /&gt;{&lt;br /&gt;if (E.Day.Date != DateTime.Now.Date)&lt;br /&gt;{&lt;br /&gt;E.Cell.BackColor = Color.AliceBlue;&lt;br /&gt;}&lt;br /&gt;// strEvents.Append("&lt;br /&gt;Events: " + i + "");&lt;br /&gt;}&lt;br /&gt;E.Cell.Controls.Add(new LiteralControl(strEvents.ToString()));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void eventcalendar_SelectionChanged(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;DataSet ds1 = new DataSet();&lt;br /&gt;DateTime dt = eventcalendar.SelectedDate.Date;&lt;br /&gt;OleDbConnection myConnection = new OleDbConnection(ConfigurationSettings.AppSettings["DBConnStr"]);&lt;br /&gt;string sql = "select starttime,endtime,title1,description from calendar where eventdt='" + dt + "'";&lt;br /&gt;&lt;br /&gt;OleDbDataAdapter da = new OleDbDataAdapter(sql, myConnection);&lt;br /&gt;da.Fill(ds1, "events");&lt;br /&gt;GridView1.DataSource = ds1;&lt;br /&gt;GridView1.DataBind();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;.aspx page:&lt;/span&gt;&lt;br /&gt;&gt;asp:calendar id="eventcalendar" TitleStyle-BackColor="#d18c25" NextPrevStyle-ForeColor="#ffffff" TitleStyle-Height="30px" ShowGridLines="true" runat="server" backcolor="white"&lt;br /&gt;width="400px" height="400px" font-size="12px"&lt;br /&gt;nextprevformat="ShortMonth" daynameformat="FirstTwoLetters"&lt;br /&gt;firstdayofweek="Sunday" OnDayRender="eventscalendar_DayRender" OnSelectionChanged="eventcalendar_SelectionChanged"&gt;&lt;br /&gt;&gt;DayStyle Font-Names="TimesRoman" /&gt;&lt;br /&gt;&gt;SelectedDayStyle Font-Names="TimesRoman" Height="20px" Width="20px" Font-Size="11px" ForeColor="#680000" BackColor="#fff0ad" /&gt;&lt;br /&gt;&gt;titlestyle Font-Names="TimesRoman" ForeColor="#680000" font-size="20px" font-bold="true" borderwidth="2px" /&gt;&lt;br /&gt;&gt;dayheaderstyle Font-Names="TimesRoman" font-size="12px" font-bold="true" /&gt;&lt;br /&gt;&gt;todaydaystyle Font-Names="TimesRoman" backcolor="#fff282" forecolor="#680000" /&gt;&lt;br /&gt;&lt;weekenddaystyle names="TimesRoman" backcolor="#fafad2" forecolor="#ff0000"&gt;&lt;br /&gt;&lt;br /&gt;&lt;othermonthdaystyle names="TimesRoman" forecolor="#cccccc"&gt;&lt;br /&gt;/asp:calendar&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-836190462589122288?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/836190462589122288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/836190462589122288'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/asp.html' title='ASP.NET: Calendar Control DayRender Sample Code'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_c2jrU6uj_ME/S1V8z2Ia0JI/AAAAAAAAAIY/hrkguuJMcxk/s72-c/Calendar2.png' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-4099402120009927179</id><published>2010-01-19T01:17:00.000-08:00</published><updated>2010-01-19T01:25:32.520-08:00</updated><title type='text'>How to Embed Flash, Videos in ASP.Net web pages</title><content type='html'>&lt;span style="font-weight:bold;"&gt;How to Embed Flash, Videos in ASP.Net web pages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To embed flash and videos we can use simple HTML embed tag for this purpose.&lt;br /&gt;&lt;br /&gt;For example.&lt;br /&gt;&lt;br /&gt;embed src="images/flash02.swf" quality="high" bgcolor="#ffffff" width="775" height="24" name="flash" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&lt;br /&gt;&lt;br /&gt;enables us to display flash files in Asp.net web pages.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Using JavaScript to display flash in Webpages.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. script type="text/javascript" src="FlashSwfObject.js"/script&lt;br /&gt;&lt;br /&gt;Use div tag where you want to display the SWF, use a unique id:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;div id="flashbanner"&gt; Your SWF will display here!!. /div &lt;br /&gt;&lt;br /&gt;We can instantiate the FlashSwfObject using below code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; script type="text/javascript"&lt;br /&gt; var so = new SWFObject('MyMedia.swf','mpl','300','250','7');&lt;br /&gt; so.addParam('allowfullscreen','true');&lt;br /&gt; so.addVariable('file','playlist.xml');&lt;br /&gt; so.addVariable('backcolor','0x000000');&lt;br /&gt; so.addVariable('autostart','true');&lt;br /&gt; so.write('flashbanner');&lt;br /&gt;/script&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-4099402120009927179?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4099402120009927179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4099402120009927179'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/how-to-embed-flash-videos-in-aspnet-web.html' title='How to Embed Flash, Videos in ASP.Net web pages'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-901019771554210358</id><published>2010-01-09T02:54:00.000-08:00</published><updated>2010-01-19T00:50:28.168-08:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-901019771554210358?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/901019771554210358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/901019771554210358'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/cool-flash-comments.html' title=''/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-71796984595093269</id><published>2010-01-07T01:24:00.000-08:00</published><updated>2010-01-07T01:29:52.308-08:00</updated><title type='text'>asp.net page life cycle</title><content type='html'>Each request for an .aspx page that hits IIS is handed over to HTTP Pipeline. HTTP Pipeline is a chain of managed objects that sequentially process the request and convert it to plain HTML text content. The start point of HTTP Pipeline is the &lt;span style="font-weight:bold;"&gt;HttpRuntime&lt;/span&gt; class. The ASP.NET infrastructure creates each instance of this class per AppDomain hosted within the worker process. &lt;span style="font-weight:bold;"&gt;HttpRuntime&lt;/span&gt; class picks up an &lt;span style="font-weight:bold;"&gt;HttpApplication&lt;/span&gt; object from an internal pool and sets it to work on the request. It finds out what class has to handle the request.&lt;br /&gt;&lt;br /&gt;Let us see the stages of execution of the ASP .NET Page indetail,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;IIS:&lt;/span&gt; IIS (Internet Information Server) is a complete Web server that makes it possible to quickly and easily deploy powerful Web sites and applications. It is the default web server used with .NET. When a Web server (for ASP.NET applications, typically IIS) receives a request, it examines the file-name extension of the requested file, determines which ISAPI extension should handle the request, and then passes the request to the appropriate ISAPI extension. (By default, ASP.NET handles file name extensions that have been mapped to it, such as .aspx, .ascx, .ashx, and .asmx.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   1. If a file name extension has not been mapped to ASP.NET, ASP.NET will not receive the request. It will be handled by the IIS. The requested page/image/file is returned without any processing.&lt;br /&gt;   2. If you create a custom handler to service a particular file name extension, you must map the extension to ASP.NET in IIS and also register the handler in your application's Web.config file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;ASPNET_ISAPI.DLL:&lt;/span&gt; This DLL is the ISAPI extension provided with ASP.NET to process the web page requests. IIS loads this DLL and sends the page request to this DLL. This DLL loads the HTTPRuntime for further processing.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;ASPNET_WP.EXE:&lt;/span&gt; Each worker process (ASPNET_WP.EXE) contains an Application Pool. Each Application Pool can contain any number of Applications. Application Pool is also called as AppDomain. When a web page is requested, IIS looks for the application pool under which the current application is running and forwards the request to the respective worker process.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Pipeline:&lt;/span&gt; HTTP Pipeline is the general-purpose framework for server-side HTTP programming that serves as the foundation for ASP.NET pages as well as Web Services. All the stages involved from creating HTTP Runtime to HTTP Handler is called HTTP Pipeline.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Runtime:&lt;/span&gt; Each AppDomain has its own instance of the HttpRuntime class—the entry point in the pipeline. The HttpRuntime object initializes a number of internal objects that will help carry the request out. The HttpRuntime creates the context for the request and fills it up with any HTTP information specific to the request. The context is represented by an instance of the HttpContext class. Another helper object that gets created at such an early stage of the HTTP runtime setup is the text writer—to contain the response text for the browser. The text writer is an instance of the HttpWriter class and is the object that actually buffers any text programmatically sent out by the code in the page. Once the HTTP runtime is initialized, it finds an application object to fulfill the request. The HttpRuntime object examines the request and figures out which application it was sent to (from the pipeline's perspective, a virtual directory is an application).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Context:&lt;/span&gt; This is created by HTTP Runtime. The HttpContext class contains objects that are specific to the current page request, such as the HttpRequest and HttpResponse objects. You can use this class to share information between pages. It can be accessed with Page.Context property in the code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Request:&lt;/span&gt; Provides access to the current page request, including the request headers, cookies, client certificate, query string, and so on. You can use this class to read what the browser has sent. It can be accessed with Page.Request property in the code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Response:&lt;/span&gt; Provides access to the output stream for the current page. You can use this class to inject text into the page, to write cookies, and more. It can be accessed with Page.Response property in the code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Application:&lt;/span&gt; An application object is an instance of the HttpApplication class—the class behind the global.asax file. HTTPRuntime uses HttpApplicationFactory to create the HTTPApplication object. The main task accomplished by the HTTP application manager is finding out the class that will actually handle the request. When the request is for an .aspx resource, the handler is a page handler—namely, an instance of a class that inherits from Page. The association between types of resources and types of handlers is stored in the configuration file of the application. More exactly, the default set of mappings is defined in the &lt;httpHandlers&gt; section of the machine.config file. However, the application can customize the list of its own HTTP handlers in the local web.config file. The line below illustrates the code that defines the HTTP handler for .aspx resources.&lt;br /&gt;&lt;br /&gt;add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HttpApplicationFactory:&lt;/span&gt; Its main task consists of using the URL information to find a match between the virtual directory of the URL and a pooled HttpApplication object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Module:&lt;/span&gt; An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request. They also let you examine the outgoing response and modify it. ASP.NET uses modules to implement various application features, which include forms authentication, caching, session state, and client script services. In each case, when those services are enabled, the module is called as part of a request and performs tasks that are outside the scope of any single page request. Modules can consume application events and can raise events that can be handled in the Global.asax file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;HTTP Handler:&lt;/span&gt; An ASP.NET HTTP handler is the process that runs in response to a request that is made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request a .aspx file, the request is processed by the page handler. We can write our own handler and handler factory if we want to handle the page request in a different manner.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note:&lt;/span&gt; HTTP modules differ from HTTP handlers. An HTTP handler returns a response to a request that is identified by a file name extension or family of file name extensions. In contrast, an HTTP module is invoked for all requests and responses. It subscribes to event notifications in the request pipeline and lets you run code in registered event handlers. The tasks that a module is used for are general to an application and to all requests for resources in the application.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Life Cycle of Page&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   1. Web page request comes from browser.&lt;br /&gt;   2. IIS maps the ASP.NET file extensions to ASPNET_ISAPI.DLL, an ISAPI extension provided with ASP.NET.&lt;br /&gt;   3. ASPNET_ISAPI.DLL forwards the request to the ASP.NET worker process (ASPNET_WP.EXE or W3P.EXE).&lt;br /&gt;   4. ISAPI loads HTTPRuntime and passes the request to it. Thus, HTTP Pipelining has begun.&lt;br /&gt;   5. HTTPRuntime uses HttpApplicationFactory to either create or reuse the HTTPApplication object.&lt;br /&gt;   6. HTTPRuntime creates HTTPContext for the current request. HTTPContext internally maintains HTTPRequest and HTTPResponse. &lt;br /&gt;   7. HTTPRuntime also maps the HTTPContext to the HTTPApplication which handles the application level events.&lt;br /&gt;   8. HTTPApplication runs the HTTPModules for the page requests.&lt;br /&gt;   9. HTTPApplication creates HTTPHandler for the page request. This is the last stage of HTTPipelining.&lt;br /&gt;  10. HTTPHandlers are responsible to process request and generate corresponding response messages.&lt;br /&gt;  11. Once the request leaves the HTTPPipeline, page level events begin.&lt;br /&gt;  12. Page Events are as follows: PreInit, Init, InitComplete, PreLoad, Load, Control events (Postback events), Load Complete, PreRender, SaveStateComplete, Render and Unload.&lt;br /&gt;  13. HTTPHandler generates the response with the above events and sends back to the IIS which in turn sends the response to the client browser.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Events in the Life Cycle of Page&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;PreInit:&lt;/span&gt; All the Pre and Post events are introduced as part of .NET Framework 2.0. As the name suggests, this event is fired before the Init method is fired. Most common functionalities implemented in this method include:&lt;br /&gt;&lt;br /&gt;   1. Check the IsPostBack property&lt;br /&gt;   2. Set the master page dynamically&lt;br /&gt;   3. Set the theme property of the page dynamically&lt;br /&gt;   4. Read or Set the profile property values&lt;br /&gt;   5. Re-create the dynamic controls&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Init:&lt;/span&gt; This event is raised after all controls in the page are initialized and any skin settings have been applied. This event is used to read or initialize control properties. It can be used to register events for some controls for which the events are not specified in the aspx page.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Ex:&lt;/span&gt; OnClick event of the Button can be registered in the Init rather than specifying in the OnClick property of the Button in the aspx page.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;InitComplete:&lt;/span&gt; Use this event for processing tasks that require all initialization to be complete.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;PreLoad:&lt;/span&gt; Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Load:&lt;/span&gt; The Page calls the OnLoad event method on the Page, then recursively does the same for each child control, which does the same for each of its child controls until the page and all controls are loaded. Use the OnLoad event method to set properties in controls and establish database connections.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Control events:&lt;/span&gt; Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.&lt;br /&gt;&lt;br /&gt;LoadComplete: Use this event for tasks that require that all other controls on the page be loaded.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;PreRender:&lt;/span&gt; This is the last event raised before the HTML code is generated for the page. The PreRender event also occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;SaveStateComplete:&lt;/span&gt; Before this event occurs, ViewState has been saved for the page and for all controls. Any changes to the page or controls at this point will be ignored.&lt;br /&gt;Use this event to perform tasks that require view state to be saved, but that do not make any changes to controls.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Render:&lt;/span&gt; This is the stage where the HTML code for the page is rendered. The Page object calls the Render method of each control at this stage. All ASP.NET Web server controls have a Render method that writes out the control's markup that is sent to the browser.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;UnLoad: &lt;/span&gt;This event occurs for each control and then for the page. In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.&lt;br /&gt;For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-71796984595093269?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/71796984595093269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/71796984595093269'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2010/01/aspnet-page-life-cycle.html' title='asp.net page life cycle'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-4020413278514018145</id><published>2009-12-29T06:01:00.001-08:00</published><updated>2009-12-29T06:03:33.778-08:00</updated><title type='text'>Automatically Generate Stored Procedures with Visual Studio</title><content type='html'>This is one of those tucked-away features in Visual Studio that, once you find it, can make you slap your forehead so hard that it hurts. Warning: You may need an aspirin after reading this.&lt;br /&gt;Notes:&lt;br /&gt;&lt;br /&gt;I'm using Microsoft Visual Studio Team System 2008. It also works with the Express editions (thanks to @bhitalks for checking this). &lt;br /&gt;&lt;br /&gt;I'm also using SQL Server Express 2005. To get this to work on my system, I had to download and install: SQLSysClrTypes.msi.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 1:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Right mouse-click the App_Code folder in the application and select "Add New Item..." When the "Add New Item" window appears, select DataSet. It doesn't matter what you name the DataSet but remember it for later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 2:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Right mouse click in the XSD window and select "Add, TableAdapter…"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 3:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After a few seconds, the "Choose Your Data Connection" window should appear. Choose, or create, a connection and click "Next".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 4:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here's the magic. In the "Choose a Command Type" window, choose "Create new stored procedures" and click "Next."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 5:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Enter an SQL select statement for a single table and click "Next."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 6:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The "Create the Stored Procedures" window appears. Rename the stored procedures to something meaningful and click "Next", or go ahead and click "Finish." Since I selected the Employees table, I renamed the procedures with the Employee prefix. You can click Preview SQL Script to see what is going to be run:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 7:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You should see the Wizard Results window…click "Finish" one more time and the Stored Procedures will be created.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Step 8:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Delete the .XSD file from the App_Code directory that was created in Step 1. It's not needed.&lt;br /&gt;You are done.&lt;br /&gt;&lt;br /&gt;Here's how the generated Stored Procedures look in SQL Server Management Studio:&lt;br /&gt;&lt;br /&gt;The generated SQL code is very clean. Of course, you can modify it to fit your requirements.&lt;br /&gt;&lt;br /&gt;Now, ain't that better than typing them by hand?&lt;br /&gt;&lt;br /&gt;I hope someone finds this useful.&lt;br /&gt;&lt;br /&gt;Steve Wellens&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-4020413278514018145?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4020413278514018145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/4020413278514018145'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/automatically-generate-stored.html' title='Automatically Generate Stored Procedures with Visual Studio'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-3059840373949324252</id><published>2009-12-29T05:55:00.000-08:00</published><updated>2009-12-29T06:49:17.008-08:00</updated><title type='text'>Casting / Converting in .NET via ASP.NET Weblogs</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Level&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Beginner&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The basic thing at least you code is converting one type to other. There are so many methods and a dedicated class (Convert class) provided in .Net framework for the same. And Microsoft has provided better approaches and practices for efficient conversion like TryParse. Here, I am sharing my experience for casting and converting one type to other. In this post we see the basic data types like string, int and DateTime.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;What are the problems?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Developers follow different approaches for getting the desired result. In my team I have seen the most usage of ToString. Whenever there is a need of string, we used to put .ToString() and for other data types, Convert.Whatever. Is it correct? Well, .Net will not have control on the input object what you have provided. I mean, it will throw compile errors if the expected type is not provided, but during runtime only it can say whether the provided input can be converted or not. Let’s assume a simple scenario. Let’s assume that this blog posts have post id and based on post id the data is retrieved. On click of any post, the page requests for corresponding post by passing this post id as query string or directly from URL(if is MVC). Since, I know the post id is integer, am using Convert.ToInt32 method to convert a string to int. This will work perfectly in normal conditions. But as said "Never trust external data", what happens, if the user changes id manually?? What happens if url weblogs.asp.net/fayaz/posts/csharp/123(typical MVC style) is modified to weblogs.asp.net/fayaz/posts/csharp/123abc?? Exception... And I feel application should not throw Exceptions for these small things. We can handle it in better way and can pass a message to user that invalid id is provided or some better way of handling.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Let’s Start&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let’s see the better approach for string, int and date time.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;to String&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The most common operation performed by any developer is converting a type to String. This can be offered to any type since all types are inherited from object and any object can be converted to string. Generally there are two ways to convert to string. One is ToString from Convert class and the other is ToString method in each type. If you search for what is the difference between Convert.ToString() and .ToString(), you will get tons of sites explaining the difference. And that will be the way of handling nulls. A Convert.ToString will return empty if the passed object is null, whereas .ToString() throws a NullReference exception, the most loved "Object reference not set to an instance of an object".&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string nullString = null;&lt;br /&gt;&lt;br /&gt;string resultString = string.Empty;&lt;br /&gt;&lt;br /&gt;resultString = Convert.ToString(nullString); // returns empty&lt;br /&gt;&lt;br /&gt;resultString = nullString.ToString(); // throws NullReferenceException&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Obviously, we should use Convert.ToString where there are chances of null, like casting a session or viewstate to string. There are lots of scenarios like everywhere we can expect null. So, use Convert.ToString. Do you like ToString more than Convert.ToString?? Well, I love ToString and am used to it. Typing Convert.ToString and using every where is pretty difficult for me. Then I followed ExtensionMethods(framework should be 3.0 or Higher). I wrote an extension method for the same.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;public static class ExtensionMethods&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    public static string ToStringOrEmpty(this object value)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        return value == null ? string.Empty : value.ToString();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;If you use exntension methods, then the code snippet would be...&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string nullString = null;&lt;br /&gt;string resultString = nullString.ToStringOrEmpty();&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;to Int&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We can convert to int by using Convert.ToInt32 and int.Parse. The difference would be the same as we discussed in ToString. If null is passed to Convert.ToInt32, it returns default of int i.e., 0(zero). Whereas int.Parse throws ArguementNull exception. The difference is clear. Convert.ToInt32 has 19 over loaded methods including object, where as int.Parse has only 4 overloaded methods (no object). So, Convert.ToInt32 can handle null also.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string nullString = null;&lt;br /&gt;&lt;br /&gt;int resultInt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;resultInt = Convert.ToInt32(nullString); // returns 0&lt;br /&gt;&lt;br /&gt;resultInt = int.Parse(nullString); // throws ArguementNullException&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Ok. We handled null a better way. Is it enough?? What if the value is some text which cannot be converted to int?? Is Convert.ToInt32 is handling this?? No, if you are passing an invalid text to convert it into int, then we get Format exception, "Input string was not in a correct format."&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string invalidInt = "abc";&lt;br /&gt;&lt;br /&gt;int resultInt;&lt;br /&gt;&lt;br /&gt;resultInt = Convert.ToInt32(invalidInt); // throws FormatException&lt;br /&gt;&lt;br /&gt;resultInt = int.Parse(invalidInt); // throws FormatException&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here it comes, the wonderful feature "TryParse". TryParse is similar to int.Parse, except it does not throw exception if the conversion fails.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string invalidInt = "abc";&lt;br /&gt;&lt;br /&gt;int resultInt;&lt;br /&gt;&lt;br /&gt;bool isInteger = int.TryParse(invalidInt, out resultInt); // resultInt = 0, isInteger = false&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Check, if the return bool is true. If false, say that, the input is invalid.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;If you use .net 3.0 or higher, then define your own extension method, ToInt&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;public static class ExtensionMethods&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    public static bool IsInt(this string value)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        int num;&lt;br /&gt;&lt;br /&gt;        return int.TryParse(value, out num);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    public static int ToInt(this string value)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        int num;&lt;br /&gt;&lt;br /&gt;        int.TryParse(value, out num);&lt;br /&gt;&lt;br /&gt;        return num;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here, we have two extension methods offered for a string. One is to check whether the input can be converted to int. And the other is returning int, if valid, else returning 0(zero).&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;to DateTime&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is similar to int discussion. So, am not going to elaborate. For null, Convert.ToDateTime returns default of DateTime, i.e., 1/1/0001 12:00:00 AM and DateTime.Parse throws exception.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string nullString = null;&lt;br /&gt;&lt;br /&gt;DateTime resultDateTime;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;resultDateTime = Convert.ToDateTime(nullString); // returns 1/1/0001 12:00:00 AM&lt;br /&gt;&lt;br /&gt;resultDateTime = DateTime.Parse(nullString); // throws ArguementNullException&lt;br /&gt;&lt;br /&gt;And for invalid data to be converted to DateTime...&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;string invalidDateTime = "12-12-12 12:12:12 AP";&lt;br /&gt;&lt;br /&gt;DateTime resultDateTime;&lt;br /&gt;&lt;br /&gt;bool isDateTime = DateTime.TryParse(invalidDateTime, out resultDateTime); // resultDateTime = 1/1/0001 12:00:00 AM, isDateTime = false&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;And Extension Methods will be&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;public static class ExtensionMethods&lt;br /&gt;&lt;br /&gt;{  &lt;br /&gt;&lt;br /&gt;    public static bool IsDateTime(this string value)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        DateTime dt;&lt;br /&gt;&lt;br /&gt;        return DateTime.TryParse(value, out dt);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    public static DateTime ToDateTime(this string value)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        DateTime dt;&lt;br /&gt;&lt;br /&gt;        DateTime.TryParse(value, out dt);&lt;br /&gt;&lt;br /&gt;        return dt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The views I have shared are better IMHO. They may not necessarily confirm to best practice. I am glad; if someone suggests me some better approaches. Will try to post converting objects from one form to other form shortly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-3059840373949324252?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3059840373949324252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3059840373949324252'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/casting-converting-in-net-via-aspnet.html' title='Casting / Converting in .NET via ASP.NET Weblogs'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-701455235257122164</id><published>2009-12-18T02:03:00.001-08:00</published><updated>2009-12-18T02:04:49.714-08:00</updated><title type='text'>http://geekswithblogs.net/dotNETvinz/archive/2008/02.aspx</title><content type='html'>this is new asp.net blog&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;http://geekswithblogs.net/dotNETvinz/archive/2008/02.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-701455235257122164?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/701455235257122164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/701455235257122164'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/httpgeekswithblogsnetdotnetvinzarchive2.html' title='http://geekswithblogs.net/dotNETvinz/archive/2008/02.aspx'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-1442434223893405155</id><published>2009-12-18T01:54:00.001-08:00</published><updated>2009-12-18T02:00:25.532-08:00</updated><title type='text'>GridView Insert, Edit, Update and Delete – The Ado.Net way</title><content type='html'>&lt;span style="font-weight:bold;"&gt;http://geekswithblogs.net/dotNETvinz/archive/2009/02/22/gridview-insert-edit-update-and-delete--the-ado.net-way.aspx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; GridView Insert, Edit, Update and Delete – The Ado.Net way&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This demo is a continuation of my previous example “Binding GridView with Data”. If you are not familiar of binding the GridView the ado.net way then I would suggest looking at my previous example first before you proceed to this example.&lt;br /&gt;&lt;br /&gt;Basically, this demo describes the basic way to do INSERT, EDIT, UPDATE  and DELETE data in ASPNET GridView Control using the ADO.NET way. &lt;br /&gt;&lt;br /&gt;STEP  1: Creating  a DataBase Table&lt;br /&gt;&lt;br /&gt;In this demo, I presumed that you already have a basic background on how to create a simple database table. In this example, this time I used my own database called SampleDB which has Customers Table and basically contains the following field columns:&lt;br /&gt;&lt;br /&gt;CustomerID – PK&lt;br /&gt;&lt;br /&gt;CompanyName&lt;br /&gt;&lt;br /&gt;ContactName&lt;br /&gt;&lt;br /&gt;ContactTitle&lt;br /&gt;&lt;br /&gt;Address&lt;br /&gt;&lt;br /&gt;Country&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;STEP 2: Setting Up the Connection String&lt;br /&gt;&lt;br /&gt;      connectionStrings&lt;br /&gt;&lt;br /&gt;            add name="DBConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SampleDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/&lt;br /&gt;&lt;br /&gt;      /connectionStrings&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;STEP 3: Setting up the GUI&lt;br /&gt;&lt;br /&gt;Just for the simplicity of this demo, I set up the GUI like this:&lt;br /&gt;&lt;br /&gt;html xmlns="http://www.w3.org/1999/xhtml" &lt;br /&gt;&lt;br /&gt;head runat="server"&lt;br /&gt;&lt;br /&gt;    title&lt;br /&gt;GridView Data Manipulation&lt;br /&gt;/title&lt;br /&gt;&lt;br /&gt;/head&lt;br /&gt;&lt;br /&gt;body&lt;br /&gt;&lt;br /&gt;    form id="form1" runat="server"&lt;br /&gt;&lt;br /&gt;    div&lt;br /&gt;&lt;br /&gt;        table cellpadding="0" cellspacing="0"&lt;br /&gt;&lt;br /&gt;            tr&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Company ID&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Company&lt;br /&gt;/td&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Name&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Title&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Address&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px; height: 19px;"&lt;br /&gt;&lt;br /&gt;                    Country&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            /tr&lt;br /&gt;&lt;br /&gt;            tr&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:TextBox ID="TextBox1" runat="server"/&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:TextBox ID="TextBox2" runat="server"/&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    &lt;asp:TextBox ID="TextBox3" runat="server"/&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:TextBox ID="TextBox4" runat="server"/&lt;br /&gt;/td&gt;&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:TextBox ID="TextBox5" runat="server"/&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:TextBox ID="TextBox6" runat="server"/&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;                td style="width: 100px"&lt;br /&gt;&lt;br /&gt;                    asp:Button ID="Button1" runat="server" Text="Add New" OnClick="Button1_Click" /&lt;br /&gt;/td&lt;br /&gt;&lt;br /&gt;            /tr&lt;br /&gt;&lt;br /&gt;        /table&lt;br /&gt;&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;        asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="true"&lt;br /&gt;&lt;br /&gt;        Columns&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="CustomerID" HeaderText="ID" ReadOnly="true"/&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="CompanyName" HeaderText="Company"/&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="ContactName" HeaderText="Name"/&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="ContactTitle" HeaderText="Title" /&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="Address" HeaderText="Address"/&lt;br /&gt;&lt;br /&gt;            asp:BoundField DataField="Country" HeaderText="Country"/&lt;br /&gt;&lt;br /&gt;        /Columns&lt;br /&gt;&lt;br /&gt;        /asp:GridView&lt;br /&gt;&lt;br /&gt;    /div&lt;br /&gt;&lt;br /&gt;    /form&lt;br /&gt;&lt;br /&gt;/body&lt;br /&gt;&lt;br /&gt;/html&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Note:  I have set the CustomerID field to ReadOnly so that the field cannot be edited.&lt;br /&gt;&lt;br /&gt;STEP 4: Binding GridView with Data&lt;br /&gt;&lt;br /&gt;I will not elaborate on this step because I already describe the details in my previous example about “Binding GridView with Data”. Here are the code blocks for binding the GridView.&lt;br /&gt;&lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        if (!IsPostBack)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            BindGridView();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    private string GetConnectionString()&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        return System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    #region Bind GridView&lt;br /&gt;&lt;br /&gt;    private void BindGridView()&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        DataTable dt = new DataTable();&lt;br /&gt;&lt;br /&gt;        SqlConnection connection = new SqlConnection(GetConnectionString());&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Open();&lt;br /&gt;&lt;br /&gt;            string sqlStatement = "SELECT Top(10)* FROM Customers";&lt;br /&gt;&lt;br /&gt;            SqlCommand cmd = new SqlCommand(sqlStatement, connection);&lt;br /&gt;&lt;br /&gt;            SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;              sqlDa.Fill(dt);&lt;br /&gt;&lt;br /&gt;              if (dt.Rows.Count &gt; 0)&lt;br /&gt;&lt;br /&gt;              {&lt;br /&gt;&lt;br /&gt;                GridView1.DataSource = dt;&lt;br /&gt;&lt;br /&gt;                GridView1.DataBind();&lt;br /&gt;&lt;br /&gt;              }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (System.Data.SqlClient.SqlException ex)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;                string msg = "Fetch Error:";&lt;br /&gt;&lt;br /&gt;                msg += ex.Message;&lt;br /&gt;&lt;br /&gt;                throw new Exception(msg);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Close();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    #endregion&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now, we already know how to bind our GridView with data from database. So let’s proceed on adding a new data in GridView.&lt;br /&gt;&lt;br /&gt;STEP 5: Adding New Data in GridView&lt;br /&gt;&lt;br /&gt;As you have noticed in STEP 2, we have added six TextBox and a Button in the web form in order for us to type the information there and Insert them to the database. Now let’s create a method for executing the Update or Insert.&lt;br /&gt;&lt;br /&gt;Here are the code blocks for our Insert and Update method in the code behind:&lt;br /&gt;&lt;br /&gt;#region Insert New or Update Record&lt;br /&gt;&lt;br /&gt;    private void UpdateOrAddNewRecord(string ID, string Company, string Name, string Title, string Address, string Country, bool isUpdate)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        SqlConnection connection = new SqlConnection(GetConnectionString());&lt;br /&gt;&lt;br /&gt;        string sqlStatement = string.Empty;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        if (!isUpdate)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            sqlStatement = "INSERT INTO Customers"+&lt;br /&gt;&lt;br /&gt;"(CustomerID,CompanyName,ContactName,ContactTitle,Address,Country)" +&lt;br /&gt;&lt;br /&gt;"VALUES (@CustomerID,@CompanyName,@ContactName,@ContactTitle,@Address,@Country)";&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        else&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            sqlStatement = "UPDATE Customers" +&lt;br /&gt;&lt;br /&gt;                           "SET CompanyName = @CompanyName,&lt;br /&gt;&lt;br /&gt;                           ContactName = @ContactName," +&lt;br /&gt;&lt;br /&gt;                           "ContactTitle = @ContactTitle,Address = &lt;br /&gt;&lt;br /&gt;                           @Address,Country = @Country" +&lt;br /&gt;&lt;br /&gt;                           "WHERE CustomerID = @CustomerID,";&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Open();&lt;br /&gt;&lt;br /&gt;            SqlCommand cmd = new SqlCommand(sqlStatement, connection);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@CustomerID", ID);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@CompanyName", Company);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@ContactName", Name);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@ContactTitle", Title);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@Address", Address);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@Country", Country);&lt;br /&gt;&lt;br /&gt;            cmd.CommandType = CommandType.Text;&lt;br /&gt;&lt;br /&gt;            cmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (System.Data.SqlClient.SqlException ex)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            string msg = "Insert/Update Error:";&lt;br /&gt;&lt;br /&gt;            msg += ex.Message;&lt;br /&gt;&lt;br /&gt;            throw new Exception(msg);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Close();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    #endregion&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The UpdateOrAddNewRecord is a method that takes seven parameters.  Six of those paramaters basically comes from the TextBox values that were entered in the page. The last parameter is a boolean value which tells the method whether to execute an Insert (false) or Update (true). Default is true.&lt;br /&gt;&lt;br /&gt;Here’s the code block for calling the method UpdateOrAddNewRecord on Button_Click event and pass the corresponding parameters needed:&lt;br /&gt;&lt;br /&gt;    protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        UpdateOrAddNewRecord(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, false);&lt;br /&gt;&lt;br /&gt;        //Re Bind GridView to reflect changes made&lt;br /&gt;&lt;br /&gt;        BindGridView();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;As you can see from above, We have called the BindGridView() method again in order to reflect the changes made and display the new added data in the GridView. See output below with red mark.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;STEP 6: Edit and Update Records In GridView&lt;br /&gt;&lt;br /&gt;One of the good things about GridView is that it provides a built-in CommandField Buttons which allows us to perform certain actions like editing, updating,deleting and selecting of GridView data.&lt;br /&gt;&lt;br /&gt;To add those command fields mentioned in the GridView you can follow these few steps below:&lt;br /&gt;&lt;br /&gt;1.       Switch to Design View&lt;br /&gt;&lt;br /&gt;2.       Right Click on the GridView and Select  --&gt; Show Smart Tag --&gt; Add New Columns&lt;br /&gt;&lt;br /&gt;3.       On the List Select CommandField&lt;br /&gt;&lt;br /&gt;4.       Check Delete and Edit/Update options then OK&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;As you can see the Edit and Delete CommandField are automatically added in the last column of GridView.  Now we can start to write our codes for editing and updating the information in the GridView.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;In-order to perform Edit and Update in GridView we need to use three events ( GridView_RowEditing, GridView_RowCancelingEdit , GridView_RowUpdating). For those who do not know on how to generate Events in GridView you can follow these steps below:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;1.       Switch to Design View in Visual Studio Designer&lt;br /&gt;&lt;br /&gt;2.       Click on the GridView&lt;br /&gt;&lt;br /&gt;3.       Navigate to the GridView Property Pane and then SWITCH to Event Properties&lt;br /&gt;&lt;br /&gt;4.       From there you would be able to find the list of events including those three  events mentioned above&lt;br /&gt;&lt;br /&gt;5.       Double Click on that to generate the Event handler for you&lt;br /&gt;&lt;br /&gt;6.       Then write the codes there&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here’s the code for each events:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;        GridView1.EditIndex = e.NewEditIndex; // turn to edit mode&lt;br /&gt;&lt;br /&gt;        BindGridView(); // Rebind GridView to show the data in edit mode&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;        GridView1.EditIndex = -1; //swicth back to default mode&lt;br /&gt;&lt;br /&gt;        BindGridView(); // Rebind GridView to show the data in default mode&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;        //Accessing Edited values from the GridView&lt;br /&gt;&lt;br /&gt;        string id = GridView1.Rows[e.RowIndex].Cells[0].Text; //ID&lt;br /&gt;&lt;br /&gt;        string company = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text; //Company&lt;br /&gt;&lt;br /&gt;        string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text; //Name&lt;br /&gt;&lt;br /&gt;        string title = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text; //Title&lt;br /&gt;&lt;br /&gt;        string address = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text; //Address&lt;br /&gt;&lt;br /&gt;        string country = ((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text; //Country&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        UpdateOrAddNewRecord(id,company,name,title,address,country,true); // call update method&lt;br /&gt;&lt;br /&gt;        GridView1.EditIndex = -1;&lt;br /&gt;&lt;br /&gt;        BindGridView(); // Rebind GridView to reflect changes made&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;STEP 7: Perform Delete in GridView&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Since we are using the Built-in Delete CommandField Button in GridView, we can use the GridView_RowDeleting event to delete specific row in GridView.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here’s the code block for the Delete method:&lt;br /&gt;&lt;br /&gt;#region Delete Record&lt;br /&gt;&lt;br /&gt;    private void DeleteRecord(string ID)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        SqlConnection connection = new SqlConnection(GetConnectionString());&lt;br /&gt;&lt;br /&gt;        string sqlStatement = "DELETE FROM Customers WHERE CustomerID = @CustomerID";&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Open();&lt;br /&gt;&lt;br /&gt;            SqlCommand cmd = new SqlCommand(sqlStatement, connection);&lt;br /&gt;&lt;br /&gt;            cmd.Parameters.AddWithValue("@CustomerID", ID);&lt;br /&gt;&lt;br /&gt;            cmd.CommandType = CommandType.Text;&lt;br /&gt;&lt;br /&gt;            cmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (System.Data.SqlClient.SqlException ex)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            string msg = "Deletion Error:";&lt;br /&gt;&lt;br /&gt;            msg += ex.Message;&lt;br /&gt;&lt;br /&gt;            throw new Exception(msg);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            connection.Close();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Here’s the code block for calling the delete method at RowDeleting event&lt;br /&gt;&lt;br /&gt;protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   string id = GridView1.Rows[e.RowIndex].Cells[0].Text; get the id of the selected row&lt;br /&gt;&lt;br /&gt;   DeleteRecord(id);//call delete method&lt;br /&gt;&lt;br /&gt;   BindGridView();//rebind grid to reflect changes made&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;That’s it!&lt;br /&gt;&lt;br /&gt;Note: If you wan’t to display a confirmation when deleting a row in GridView then you can refer to my next example about “Display Confirmation Message on GridView Deleting”&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-1442434223893405155?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1442434223893405155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/1442434223893405155'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/gridview-insert-edit-update-and-delete.html' title='GridView Insert, Edit, Update and Delete – The Ado.Net way'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6085257178103238237</id><published>2009-12-18T01:31:00.000-08:00</published><updated>2009-12-18T01:48:25.230-08:00</updated><title type='text'>gridview row can use check box to  download file  and display excel format</title><content type='html'>1 .   script language="javascript" type="text/javascript"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    var AFID = "";&lt;br /&gt;    function GetID(rowID, AudioFileID) {&lt;br /&gt;        AFID = AudioFileID;&lt;br /&gt;        ChangeColor(rowID, 'gvAudioFiles');&lt;br /&gt;    }&lt;br /&gt;    function ChangeRowColorForMouseMove(rowID) {&lt;br /&gt;        ChangeColor1(rowID, 'gvAudioFiles');&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/script&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.  script type="text/javascript" language="javascript"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function SelectAll(CheckBox)&lt;br /&gt;{&lt;br /&gt;    TotalChkBx = parseInt('&lt;%= this.gvAudioFiles.Rows.Count %&gt;');&lt;br /&gt;    var TargetBaseControl = document.getElementById('&lt;%= this.gvAudioFiles.ClientID %&gt;');&lt;br /&gt;    var TargetChildControl = "chkSelect";&lt;br /&gt;    var Inputs = TargetBaseControl.getElementsByTagName("input");&lt;br /&gt;    for(var iCount = 0; iCount &lt; type ="="&gt;= 0)&lt;br /&gt;            Inputs[iCount].checked = CheckBox.checked;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function SelectDeSelectHeader(CheckBox)&lt;br /&gt;{   &lt;br /&gt;    TotalChkBx = parseInt('&lt;%= this.gvAudioFiles.Rows.Count %&gt;');&lt;br /&gt;    var TargetBaseControl = document.getElementById('&lt;%= this.gvAudioFiles.ClientID %&gt;');&lt;br /&gt;    var TargetChildControl = "chkSelect";&lt;br /&gt;    var TargetHeaderControl = "chkSelectAll";&lt;br /&gt;    var Inputs = TargetBaseControl.getElementsByTagName("input");&lt;br /&gt;    var flag = false;&lt;br /&gt;    var HeaderCheckBox;&lt;br /&gt;    for(var iCount = 0; iCount &lt; type ="="&gt;= 0)       &lt;br /&gt;            HeaderCheckBox = Inputs[iCount];       &lt;br /&gt;        if(Inputs[iCount] != CheckBox &amp;amp;&amp;amp; Inputs[iCount].type == 'checkbox' &amp;amp;&amp;amp; Inputs[iCount].id.indexOf(TargetChildControl,0) &gt;= 0 &amp;amp;&amp;amp; Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)&lt;br /&gt;        {       &lt;br /&gt;            if(CheckBox.checked)&lt;br /&gt;            {               &lt;br /&gt;                if(!Inputs[iCount].checked)               &lt;br /&gt;                {               &lt;br /&gt;                    flag = false;&lt;br /&gt;                    HeaderCheckBox.checked = false;                  &lt;br /&gt;                    return;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                    flag = true;               &lt;br /&gt;            }&lt;br /&gt;            else if(!CheckBox.checked)           &lt;br /&gt;                HeaderCheckBox.checked = false;                                                  &lt;br /&gt;        }       &lt;br /&gt;    }                 &lt;br /&gt;    if(flag)   &lt;br /&gt;        HeaderCheckBox.checked = CheckBox.checked   &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/script&lt;br /&gt;&lt;br /&gt;3. script type="text/javascript"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*Check box validation in gridview*/&lt;br /&gt;var TargetBaseControl = null;&lt;br /&gt;&lt;br /&gt;window.onload = function()&lt;br /&gt;{&lt;br /&gt;  try&lt;br /&gt;  {&lt;br /&gt;     //get target base control.&lt;br /&gt;     TargetBaseControl =&lt;br /&gt;       document.getElementById('&lt;%= this.gvAudioFiles.ClientID %&gt;');&lt;br /&gt;  }&lt;br /&gt;  catch(err)&lt;br /&gt;  {&lt;br /&gt;     TargetBaseControl = null;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function TestCheckBox()&lt;br /&gt;{         &lt;br /&gt;  if(TargetBaseControl == null) return false;&lt;br /&gt;&lt;br /&gt;  //get target child control.&lt;br /&gt;  var TargetChildControl = "chkSelect";&lt;br /&gt;   &lt;br /&gt;  //get all the control of the type INPUT in the base control.&lt;br /&gt;  var Inputs = TargetBaseControl.getElementsByTagName("input");&lt;br /&gt;   &lt;br /&gt;  for(var n = 0; n &lt; type ="="&gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;        Inputs[n].checked)&lt;br /&gt;      return true;   &lt;br /&gt;   &lt;br /&gt;  alert('Select at least one audio file!');&lt;br /&gt;  return false;&lt;br /&gt;}&lt;br /&gt;/script&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Gridview&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;asp:GridView ID="gvAudioFiles" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvAudioFiles_RowDataBound"  Width="100%" AllowPaging="true" AllowSorting="true" OnPageIndexChanging="gvAudioFiles_PageIndexChanging1" OnSorting="gvAudioFiles_Sorting"&gt;&lt;br /&gt;&lt;br /&gt;                                         &lt;br /&gt;                                             Columns&lt;br /&gt;&lt;br /&gt;                                                 asp:TemplateField HeaderText=""&lt;br /&gt;&lt;br /&gt;                                                     HeaderTemplate&lt;br /&gt;&lt;br /&gt;                                                         asp:CheckBox ID="chkSelectAll" runat="server"onclick="SelectAll(this);" /&gt;&lt;br /&gt;&lt;br /&gt;                                                     /HeaderTemplate&lt;br /&gt;                                                     ItemTemplate&lt;br /&gt;                                                         asp:CheckBox ID="chkSelect" runat="server" /&lt;br /&gt;                                                     /ItemTemplate&lt;br /&gt;                                                 /asp:TemplateField&lt;br /&gt;                                                 asp:BoundField DataField="DoctorName" HeaderText="Doctor Name" HeaderStyle-CssClass="submenu"&lt;br /&gt;                                                     SortExpression="DoctorName" /&lt;br /&gt;                                                 asp:TemplateField HeaderText="Audio File" HeaderStyle-CssClass="submenu"&lt;br /&gt;                                                     ItemTemplate&lt;br /&gt;                                                         asp:HyperLink ID="hlnkAudio" runat="server" Target="_blank" Text='&lt;%#Eval("AudioFileName") %&gt;'&lt;br /&gt;                                                             ToolTip="Click here to download" NavigateUrl='&lt;%#string.Concat("~/AudioFiles/",DataBinder.Eval(Container.DataItem, "UserName"),"/",Convert.ToDateTime(Eval("FileDate")).ToLongDateString(),"//", DataBinder.Eval(Container.DataItem, "AudioFileName")) %&gt;'&lt;br /&gt;                                                         /asp:HyperLink&lt;br /&gt;                                                         asp:Label ID="lblAudioFileID" runat="server" Text='&lt;%#Eval("AudioFileID") %&gt;' Visible="false" /&lt;br /&gt;                                                     /ItemTemplate&lt;br /&gt;                                                 /asp:TemplateField&lt;br /&gt;                                                 asp:TemplateField HeaderText="File Added on" HeaderStyle-CssClass="submenu" SortExpression="FileDate"&lt;br /&gt;                                                     ItemTemplate&lt;br /&gt;                                                         asp:Label ID="lblAudioFileDate" runat="server" Text='&lt;%# Convert.ToDateTime(Eval("FileDate")).ToShortDateString()%&gt;' /&lt;br /&gt;                                                     /ItemTemplate&lt;br /&gt;                                                 /asp:TemplateField&lt;br /&gt;                                             /Columns&lt;br /&gt;                                         /asp:GridView&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. Buttons&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;asp:Button ID="btnAssign" runat="server" Text="Assign" CssClass="submitbutton" OnClick="btnAssign_Click"&lt;br /&gt;                                              PostBackUrl="AssignAudioFilesToQA.aspx" /&lt;br /&gt;                                        &lt;br /&gt;                                          asp:Button ID="btnFileIDs" runat="server" Visible="false"&lt;br /&gt;/asp:Button&lt;br /&gt;                                          asp:Button ID="btnDownload" runat="server" Text="Download" OnClick="btnDownload_Click" /&lt;br /&gt;                                          asp:Button ID="Button1" runat="server" Text="Export to Excel" OnClick="Button1_Click" /&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6 c#&lt;br /&gt;&lt;br /&gt;in project add bin  this file&lt;br /&gt;&lt;br /&gt;&lt;a href="file:///D:/Streamline%20Projects/STREAMLINEMT/StreamMT/Bin/ICSharpCode.SharpZipLib.dll"&gt;ICSharpCode.SharpZipLib.dll&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. code c#&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Xml.Linq;&lt;br /&gt;using StreamlineMT.BO;&lt;br /&gt;using StreamlineMT.BLL;&lt;br /&gt;using ICSharpCode.SharpZipLib.Checksums;&lt;br /&gt;using ICSharpCode.SharpZipLib.Zip;&lt;br /&gt;using ICSharpCode.SharpZipLib.GZip;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;public partial class test : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;   protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;       VerifyRenderingInServerForm(form1);&lt;br /&gt;       Response.Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;       btnAssign.Attributes.Add("onclick", "if (!TestCheckBox()) { return false; }");&lt;br /&gt;       if (!Page.IsPostBack)&lt;br /&gt;       {&lt;br /&gt;           ViewState["sortOrder"] = "";&lt;br /&gt;           bindGridView("", "");&lt;br /&gt;       }&lt;br /&gt;       // GetAudioFiles();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   private void bindGridView(string sortExp, string sortDir)&lt;br /&gt;   {&lt;br /&gt;       AudioFileBLL objBLL = new AudioFileBLL();&lt;br /&gt;       AudioFileBO objBO = new AudioFileBO();&lt;br /&gt;       DataSet ds = new DataSet();&lt;br /&gt;       objBO.Type = "SearchFiles";&lt;br /&gt;       objBO.FromDate = "12/01/2009";&lt;br /&gt;       objBO.ToDate = "12/04/2009";&lt;br /&gt;       ds = objBLL.GetAudioFiles(objBO);&lt;br /&gt;&lt;br /&gt;       if (ds.Tables[0].Rows.Count == 0)&lt;br /&gt;&lt;br /&gt;           btnAssign.Visible = false;&lt;br /&gt;       else&lt;br /&gt;       {&lt;br /&gt;           DataView myDataView = new DataView();&lt;br /&gt;           myDataView = ds.Tables[0].DefaultView;&lt;br /&gt;           if (sortExp != string.Empty)&lt;br /&gt;           {&lt;br /&gt;               myDataView.Sort = string.Format("{0} {1}", sortExp, sortDir);&lt;br /&gt;           }&lt;br /&gt;           btnAssign.Visible = true;&lt;br /&gt;           myDataView.RowFilter = "(FileDate &gt;='12/04/2009 00:00:01') and (FileDate&lt;='12/04/2009 23:59:59')";              gvAudioFiles.DataSource = myDataView;             gvAudioFiles.DataBind();         }     }      protected void gvAudioFiles_RowDataBound(object sender, GridViewRowEventArgs e)     {         if (e.Row.RowType == DataControlRowType.DataRow)         {             //Label lblStatus = (Label)e.Row.FindControl("lblStatus");             //HyperLink hlnkAssign = (HyperLink)e.Row.FindControl("hlnkAssign");             //if (lblStatus.Text == "")             //    hlnkAssign.Visible = true;             //else             //    hlnkAssign.Visible = false;             //if (lblStatus.Text == "8")             //    e.Row.Cells[5].Style.Add("background-color", "#ffa463");              string rowID = String.Empty;             if (e.Row.RowType == DataControlRowType.DataRow)             {                 rowID = "row" + e.Row.RowIndex;                 e.Row.Attributes.Add("Id", rowID);                 // e.Row.Attributes.Add("onclick", "javascript:GetID('" + rowID + "','" + DataBinder.Eval(e.Row.DataItem, "TemplateID") + "');");                 e.Row.Attributes.Add("onmouseover", "javascript:ChangeRowColorForMouseMove('" + rowID + "');");             }         }          //Select All         if (e.Row.RowType == DataControlRowType.Header)         {             //adding an attribute for onclick event on the check box in the header              //and passing the ClientID of the Select All checkbox              //((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");         }         try         {             if (e.Row.RowType == DataControlRowType.DataRow)             {                 string strScript = "SelectDeSelectHeader(" + ((CheckBox)e.Row.Cells[0].FindControl("chkSelect")).ClientID + ");";                 ((CheckBox)e.Row.Cells[0].FindControl("chkSelect")).Attributes.Add("onclick", strScript);             }         }         catch (Exception Ex)         {             //report error         }     }      protected void btnAssign_Click(object sender, EventArgs e)     {         string fileIDs = "";         foreach (GridViewRow gr in gvAudioFiles.Rows)         {             CheckBox chkSelect = (CheckBox)gr.FindControl("chkSelect");              if (chkSelect.Checked)             {                 Label lblAudioFileID = (Label)gr.FindControl("lblAudioFileID");                 fileIDs = fileIDs + lblAudioFileID.Text + ",";                 //SqlParameter S1=new SqlParameter(             }         }         if (fileIDs != "")         {             btnFileIDs.Text = fileIDs.TrimEnd(',');             btnAssign.PostBackUrl = "AssignAudioFilesToQA.aspx?stat=audi";             //Response.Redirect("AssignAudioFilesToQA.aspx?stat=audi");         }         else         {             string popupScript = "&lt;script language="'javascript'"&gt;alert('Please select the files to assign.');&lt;/script&gt;";&lt;br /&gt;           ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), popupScript, false);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   protected void gvAudioFiles_PageIndexChanging1(object sender, GridViewPageEventArgs e)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;       gvAudioFiles.PageIndex = e.NewPageIndex;&lt;br /&gt;       bindGridView("", "");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;   protected void gvAudioFiles_Sorting(object sender, GridViewSortEventArgs e)&lt;br /&gt;   {&lt;br /&gt;       bindGridView(e.SortExpression, sortOrder);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;   public string sortOrder&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           if (ViewState["sortOrder"].ToString() == "desc")&lt;br /&gt;               ViewState["sortOrder"] = "asc";&lt;br /&gt;           else&lt;br /&gt;               ViewState["sortOrder"] = "desc";&lt;br /&gt;           return ViewState["sortOrder"].ToString();&lt;br /&gt;       }&lt;br /&gt;       set&lt;br /&gt;       {&lt;br /&gt;           ViewState["sortOrder"] = value;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   protected void btnDownload_Click(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;       ArrayList filelist = new ArrayList();&lt;br /&gt;       string fileLoc = "";&lt;br /&gt;       foreach (GridViewRow gr in gvAudioFiles.Rows)&lt;br /&gt;       {&lt;br /&gt;           CheckBox chkSelect = (CheckBox)gr.FindControl("chkSelect");&lt;br /&gt;&lt;br /&gt;           if (chkSelect.Checked)&lt;br /&gt;           {&lt;br /&gt;               HyperLink hlnkAudio = (HyperLink)gr.FindControl("hlnkAudio");&lt;br /&gt;               fileLoc = fileLoc + hlnkAudio.NavigateUrl + ",";&lt;br /&gt;               filelist.Add(hlnkAudio.NavigateUrl);&lt;br /&gt;               //SqlParameter S1=new SqlParameter(&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;       if (filelist.Count != 0)&lt;br /&gt;       {&lt;br /&gt;           fileLoc = fileLoc.TrimEnd(',');&lt;br /&gt;&lt;br /&gt;           string zipFullPath = Server.MapPath("~\\") + "DocumentFolder.zip";&lt;br /&gt;&lt;br /&gt;           ZipOutputStream zipOut = new ZipOutputStream(File.Create(zipFullPath));&lt;br /&gt;           //string[] f = { "D:\\Projects\\STREAMLINEMT\\StreamMT\\AudioFiles\\linder\\Friday, November 27, 2009\\162-13742409.VW", "D:\\Projects\\STREAMLINEMT\\StreamMT\\AudioFiles\\linder\\Friday, November 27, 2009\\13742409.Wav.wav" };&lt;br /&gt;&lt;br /&gt;           for (int i = 0; i &lt; fi =" new" entry =" new" sreader =" File.OpenRead(Server.MapPath(filelist[i].ToString()));" buff =" new" datetime =" fi.LastWriteTime;" size =" sReader.Length;" postbackurl = "AssignAudioFilesToQA.aspx?stat=audi" stat="audi" targetf =" new" contenttype = "application/zip" filename=" + targetf.Name);          FileStream sourceFile = new FileStream(@fapth, FileMode.Open);         long FileSize;         FileSize = sourceFile.Length;         byte[] getContent = new byte[(int)FileSize];         sourceFile.Read(getContent, 0, (int)sourceFile.Length);         sourceFile.Close();          Response.BinaryWrite(getContent);     }       private void exporttoGrid()     {         Response.Clear();         Response.AddHeader(" filename="FileName.xls" charset = "" contenttype = "application/vnd.xls" stringwrite =" new" htmlwrite =" new" ld =" GetDSSDuration(" popupscript = "&lt;script language="&gt;alert('" + ld + "');&lt;/script&gt;";&lt;br /&gt;       //ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), popupScript, false);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public override void VerifyRenderingInServerForm(Control control)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   public static long GetDSSDuration(string fileName)&lt;br /&gt;   {&lt;br /&gt;       FileInfo fi = new FileInfo(fileName);&lt;br /&gt;       long size = fi.Length;&lt;br /&gt;&lt;br /&gt;       long length = (long)(((size * 1.1869) - ((size / 1054) * 210)) / 1054);&lt;br /&gt;&lt;br /&gt;       if (length &gt; 1000)&lt;br /&gt;       {&lt;br /&gt;           length = (long)(length * (0.61 + ((length / 100) * 0.0005)));&lt;br /&gt;       }&lt;br /&gt;       else&lt;br /&gt;       {&lt;br /&gt;           length = (long)(length * (0.61 + ((length / 100) * 0.0015)));&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       return length;&lt;br /&gt;   }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6085257178103238237?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6085257178103238237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6085257178103238237'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/gridview-values-can-download.html' title='gridview row can use check box to  download file  and display excel format'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-709283151166947393</id><published>2009-12-18T00:38:00.000-08:00</published><updated>2009-12-18T00:44:01.371-08:00</updated><title type='text'>The Dictionary object in ASP.NET</title><content type='html'>&lt;span style="font-weight:bold;"&gt;The Dictionary Object&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Dictionary object is used to store information in name/value pairs (referred to as key and item). The Dictionary object might seem similar to Arrays, however, the Dictionary object is a more desirable solution to manipulate related data.&lt;br /&gt;&lt;br /&gt;Comparing Dictionaries and Arrays:&lt;br /&gt;· Keys are used to identify the items in a Dictionary object&lt;br /&gt;· You do not have to call ReDim to change the size of the Dictionary object&lt;br /&gt;· When deleting an item from a Dictionary, the remaining items will automatically &lt;br /&gt;&lt;br /&gt;shift up&lt;br /&gt;· Dictionaries cannot be multidimensional, Arrays can&lt;br /&gt;· Dictionaries have more built-in functions than Arrays&lt;br /&gt;· Dictionaries work better than arrays on accessing random elements frequently&lt;br /&gt;· Dictionaries work better than arrays on locating items by their content&lt;br /&gt;&lt;br /&gt;The following example creates a Dictionary object, adds some key/item pairs to it, and retrieves the item value for the key gr:&lt;br /&gt;&lt;br /&gt;&lt;%Dim dSet d=Server.CreateObject("Scripting.Dictionary")d.Add "re","Red"d.Add "gr","Green"d.Add "bl","Blue"d.Add "pi","Pink"Response.Write("The value of key gr is: " &amp; d.Item("gr"))%&gt;Output:The value of key gr is: Green&lt;br /&gt;&lt;br /&gt;The Dictionary object's properties and methods are described below: &lt;br /&gt;&lt;br /&gt;Properties&lt;br /&gt;Property Description&lt;br /&gt;CompareMode Sets or returns the comparison mode for comparing keys in a Dictionary object&lt;br /&gt;Count Returns the number of key/item pairs in a Dictionary object&lt;br /&gt;Item Sets or returns the value of an item in a Dictionary object&lt;br /&gt;Key Sets a new key value for an existing key value in a Dictionary object&lt;br /&gt;&lt;br /&gt;Methods&lt;br /&gt;Method Description&lt;br /&gt;Add Adds a new key/item pair to a Dictionary object&lt;br /&gt;Exists Returns a Boolean value that indicates whether a specified key exists in the Dictionary object&lt;br /&gt;Items Returns an array of all the items in a Dictionary object&lt;br /&gt;Keys Returns an array of all the keys in a Dictionary object&lt;br /&gt;Remove Removes one specified key/item pair from the Dictionary object&lt;br /&gt;RemoveAll Removes all the key/item pairs in the Dictionary object&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ll the keys and corresponding items in our dictionary object:&lt;br /&gt;Key Item&lt;br /&gt;green #00FF00&lt;br /&gt;red #FF0000&lt;br /&gt;aqua #00FFFF&lt;br /&gt;yellow #FFFF00&lt;br /&gt;white #FFFFFF&lt;br /&gt;fuschia #FF00FF&lt;br /&gt;black #000000&lt;br /&gt;blue #0000FF&lt;br /&gt;&lt;br /&gt;Number of key/item pairs in our dictionary: 8 &lt;br /&gt;Does a "blue" key exist: True &lt;br /&gt;Value of the item corresponding to the "blue" key: #0000FF &lt;br /&gt;Changing the value of the "blue" key's item. Its value is now: #000099 &lt;br /&gt;Changing the value of the "blue" key to "dark blue". &lt;br /&gt;All the keys and corresponding items in our dictionary object:&lt;br /&gt;Key Item&lt;br /&gt;green #00FF00&lt;br /&gt;red #FF0000&lt;br /&gt;aqua #00FFFF&lt;br /&gt;yellow #FFFF00&lt;br /&gt;white #FFFFFF&lt;br /&gt;fuschia #FF00FF&lt;br /&gt;black #000000&lt;br /&gt;dark blue #000099&lt;br /&gt;&lt;br /&gt;Bind an ASP.NET DropDownList to a Dictionary &lt;br /&gt;I have seen a lot of folks keeping data in a Dictionary&lt;,&gt;. However when it comes to binding this Dictionary with a control, they feel lost!&lt;br /&gt;&lt;br /&gt;Here's a simple way that demonstrates how to bind a Dictionary to an ASP.NET DropDownList control&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        asp:DropDownList ID="ddlRelatives" runat="server"&lt;br /&gt;&lt;br /&gt;        /asp:DropDownList&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Dictionary&lt;int, string&gt; dicRel = new Dictionary&lt;int, string&gt;(); &lt;br /&gt;&lt;br /&gt;    dicRel.Add(1, "Father"); &lt;br /&gt;&lt;br /&gt;    dicRel.Add(2, "Mother"); &lt;br /&gt;&lt;br /&gt;    dicRel.Add(3, "Brother"); &lt;br /&gt;&lt;br /&gt;    dicRel.Add(4, "Sister");&lt;br /&gt;&lt;br /&gt;    dicRel.Add(5, "Others");&lt;br /&gt;&lt;br /&gt;    ddlRelatives.DataSource = dicRel;&lt;br /&gt;&lt;br /&gt;    ddlRelatives.DataTextField = "Value";&lt;br /&gt;&lt;br /&gt;    ddlRelatives.DataValueField = "Key";&lt;br /&gt;&lt;br /&gt;    ddlRelatives.DataBind();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-709283151166947393?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/709283151166947393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/709283151166947393'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/dictionary-object-in-aspnet.html' title='The Dictionary object in ASP.NET'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-7080131043923071</id><published>2009-12-18T00:34:00.000-08:00</published><updated>2009-12-18T00:37:23.254-08:00</updated><title type='text'>Gridview Serial number</title><content type='html'>1. Add OnRowDataBound="GridView1_RowDataBound" inside your GridView declaration:&lt;br /&gt;&lt;br /&gt;    asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" ...&lt;br /&gt;&lt;br /&gt;2. Add TemplateField inside your GridView:&lt;br /&gt;&lt;br /&gt;                    asp:TemplateField HeaderText="Serial number"&lt;br /&gt;                        ItemTemplate&lt;br /&gt;                            asp:Label ID="lblSerial" runat="server"&gt;&lt;/asp:Label&gt;&lt;br /&gt;                        /ItemTemplate&lt;br /&gt;                    /asp:TemplateField&lt;br /&gt;&lt;br /&gt;3. Add this in code-behind:&lt;br /&gt;&lt;br /&gt;        int i = 1;&lt;br /&gt;        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (e.Row.RowType == DataControlRowType.DataRow)&lt;br /&gt;            {&lt;br /&gt;                Label lblSerial = (Label)e.Row.FindControl("lblSerial");&lt;br /&gt;                lblSerial.Text = i.ToString();&lt;br /&gt;                i++;&lt;br /&gt;            }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-7080131043923071?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/7080131043923071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/7080131043923071'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/gridview-serial-number.html' title='Gridview Serial number'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-6842357956194320419</id><published>2009-12-17T03:12:00.000-08:00</published><updated>2009-12-18T01:29:01.958-08:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-6842357956194320419?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6842357956194320419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/6842357956194320419'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/gridview-aspx-file-source-code.html' title=''/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-8393828311730797780.post-3828314925605971788</id><published>2009-12-14T00:22:00.000-08:00</published><updated>2009-12-14T00:23:20.043-08:00</updated><title type='text'>Gajula Mahesh Kumar</title><content type='html'>HI ALL...&lt;br /&gt;&lt;br /&gt;THIS IS  MAHESH KUMAR GAJULA.....&lt;br /&gt;&lt;br /&gt;THANKS FOR VISITING.......&lt;br /&gt;&lt;br /&gt;HAVE A NICE DAY .......&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8393828311730797780-3828314925605971788?l=gajulamaheshkumar.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3828314925605971788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8393828311730797780/posts/default/3828314925605971788'/><link rel='alternate' type='text/html' href='http://gajulamaheshkumar.blogspot.com/2009/12/gajula-mahesh-kumar.html' title='Gajula Mahesh Kumar'/><author><name>GAJULA MAHESH KUMAR</name><uri>http://www.blogger.com/profile/01213710534088712366</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_c2jrU6uj_ME/SyX2g5zQaSI/AAAAAAAAAHE/PdhuvfoCRjg/S220/Image013.jpg'/></author></entry></feed>
