alert('Oh shit !!!! Javascript is disabled!!!! ');


Showing posts with label Asp.Net Blog. Show all posts
Showing posts with label Asp.Net Blog. Show all posts

Gridview in ASP.NET

Gridview in ASP.NET

The GridView control displays data as a table and provides the capability to sort columns, page through data, and edit or delete a single record. the GridView control offers improvements such as the ability to define multiple primary key fields, improved user interface customization using bound fields and templates, and a new model for handling or canceling events.

Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.

Namespace: System.Web.UI.WebControls .
Assembly: System.Web (in System.Web.dll) .

GridView Control Features

  • Enhanced data source binding capabilities (Direct interaction with Data Source with any writing any ADO.NET code)

  • Built-in support for sorting and paging functionalities

  • Improved Design time features(Smart Panel Tag)

  • Customized pager user interface with PagerTemplate property.

  • Additional Column types(ImageField).

  • New Event model with support for pre event and post event operations

Difference between Datagrid,DataList and Data Repeater

  • Datagrid has paging while Datalist doesnt.
  • Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.
  • A repeater is used when more intimate control over html generation is required.
  • When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radio button list are used as they involve fewer overheads than a Datagrid.

 

Design of Gridview:

.CS Code


  protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection con;
       
        OleDbDataAdapter da;
       
        string conn = System.Configuration.ConfigurationManager.AppSettings
[
"x"].ToString(); con = new OleDbConnection(conn); da = new OleDbDataAdapter("select purchase1,tax,issue_date from purchase"
, con); DataSet ds=new DataSet(); da.Fill( ds, "purchase"); GridView1.DataSource = ds.Tables["purchase"]; GridView1.DataBind(); }

.ASPX Code




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
" "http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <style type="text/css"> .style1 { width: 100%; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" Height="341px" onselectedindexchanged="GridView1_SelectedIndexChanged"
Width="192px"> <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /> <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True"
ForeColor="White" /> <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> </asp:GridView> <table class="style1"> <tr> <td> <marquee direction="up" behavior="scroll" onmouseover="this.stop()" onmouseout="this.start()" scrollamount="2"> <a href="#">Retail Express Distribution</a><br /><br /> <a href="#">Global Express Consolidation Service</a><br /><br /> <a href="#">Import Express </a><br /><br /> <a href="#">Collect charges and cash on delivery</a><br /><br
/></marquee>
&nbsp;</td> <td> &nbsp;</td> </tr> <tr> <td> &nbsp;</td> <td> &nbsp;</td> </tr> </table> </div> </form> </body> </html>

Introduction Of Master Page

Master Page

Microsoft  ASP.NET 2.0 introduces a new feature .Master Pages. that permits you to define common user interface (UI) elements and common structure in a template that can be applied to multiple content pages in a Web application. Standard elements are, for example, navigational menus, logos, and other stock graphical elements. This allows you to have a common appearance and functionality across your Web site, avoids duplication of code, and makes the site easier to maintain. If the content pages are based on the master page, all the elements defined in the master page would automatically be defined in the content pages.

The page layout for Master Pages is easy to create, simple to maintain, and simple to assign to a Web application. The Master page provides a single point of reference for all pages to display standardized Web content. Master pages are completely transparent to end users and permit developers to create Web sites where pages share a common layout. Defining a Master page is similar to defining a normal page, but saving a Master page is    different from saving a normal page. You must save the Master pages by using the .master file extension.

How to Add Master Page in Your Application

Adding a master page to your web application is straight forward. Just right click on the project and select "Add New Item" and than select "Master Page". This will add the master page to your project.
The master page already has the content place holder control which is used to hold and display your contents. Let's delete that content placeholder and add it by our self. In this case we will create two content place holders. One will be on the left and other one on the right .After you insert the content placeholder control inside your table your master page will look something like this:
 

Using the master page in your aspx pages

Just add a new aspx page and name it as "first .aspx". Now you want to use the Sample1.master file in your aspx page. Just go to the html view of your page and add a Master Page File attribute in the page directive and delete all the other html that is written in the aspx page. The Master Page File attribute denotes that the Page is inheriting from the master page.

<%@ Page  Master Page File="~/Sample1.master"  %>

 

Server Side State Management

Server Side State Management

When users visit Web sites it becomes necessary to maintain session related and controls related information. In an HTTP exchange between a browser and a remote host, session related information which identifies state, such as a unique session ID, information about the user's preferences or authorization level is preserved. Note that sessions are maintained in the data being exchanged.

State Management is the process by which we maintain session related information and additional information about the controls and its state. The necessity of state management arises when multiple users request for the same or different Web Pages of a Web Site. State management can be accomplished using Client Side options or the Server side options.

Session State: Its nothing but defined as a period of time shared between the web application and user. Every user has individual session. Items/Objects can be placed into the Session which would only define these object for that user. Session contains key variables which help to identify the related values. This can be thought of as a hash table. Each user would represent a different key node in the hash identifying unique values. The Session variables will be clear by the application which can clear it, as well as through the timeout property in the web config file. Usually the timeout is 20 minutes by default. ASP.NET allows you to save values using session state, a storage mechanism that is accessible from all pages requested by a single Web browser session. Therefore, you can use session state to store user-specific information. Session state is similar to application state, except that it is scoped to the current browser session. If different users are using your application, each user session has a different session state. In addition, if a user leaves your application and then returns later after the session timeout period, session state information is lost and a new session is created for the user. Session state is stored in the Session key/value dictionary.

Session Variables are stored on the server, can hold any type of data including references, they are similar to global variables in a windows application and use HTTP cookies to store a key with which to locate user's session variables .The collection of session variables is indexed by the name of the variable or by an integer index. Session variables are created by referring to the session variable by name. You do not have to declare a session variable or explicitly add it to the collection.

Example:

//Storing informaton in session state
Session["username"] = "Ashish";

//Retrieving information from session state
string str = Session["username"];

Application State:

Application State is used to store information which is shared among users of the ASP.Net web application. Application state is stored in the memory of the windows process which is processing user requests on the web server. Application state is useful in storing small amount of often-used data. If application state is used for such data instead of frequent trips to database, then it increases the response time/performance of the web application.

In ASP.Net, application state is an instance of HttpApplicationState class and it exposes key-value pairs to store information. Its instance is automatically created when a first request is made to web application by any user and same state object is being shared across all subsequent users.

Application state can be used in similar manner as session state but it should be noted that many user might be accessing application state simultaneously so any call to application state object needs to be thread safe. This can be easily achieved in ASP.Net by using lock keyword on the statements which are accessing application state object. This lock keyword places a mutually exclusive lock on the statements and only allows a single thread to access the application state at a time.

Code Sample

//Stroing information in application state
lock (this)
{ 
       Application["username"] = "william";
}

//Retrieving value from application state
lock (this)
{
      string str = Application["username"].ToString();
}

Query String In ASP.NET

Query String In ASP.NET

Query string is used to Pass the values or information form one page to another page.

The query string  is a holdover from the ASP days of web programming. You will see this a lot when you are surfing around the internet. Basically, it is passing information to the next page with the URL .You can use a query string to submit data back to your page or to another page through the URL. Query strings provide a simple but limited way of maintaining some state information.

The advantages of using query strings are

  • No server resources required. The query string is contained in the HTTP request for a specific URL.
  • Broad support. Almost all browsers and client devices support passing values in a query string
  • it is very easy

The disadvantages of using query strings are

  • Security. The information in the query string is directly visible to the user via the browser user interface. The query values are exposed to the Internet via the URL so in some cases security may be an issue. 
  • Limited capacity. Most browsers and client devices impose a 255-character limit on URL length

.CS CODE


 private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("Default.aspx?Name=" +
this.txtName.Text + "&LastName=" +
this.txtLastName.Text);
} 

Our first code part builds a query string for your application and send contents of your textboxes to second page. Now how to retrieve this values from second page.

Put this code to second page page_load.

.ASPX CODE


private void Page_Load(object sender, System.EventArgs e)
{
this.txtBox1.Text = Request.QueryString["Name"];
this.txtBox2.Text = Request.QueryString["LastName"];
} 

Cookies in ASP.NET

Cookies in ASP.NET

A cookie is a small bit of text file that browser creates and stores on your machine (hard drive). Cookie is a small piece of information stored as a string. Web server sends the cookie and browser stores it, next time server returns that cookie .Cookies are mostly used to store the information about the user. Cookies are stores on the client side .To store data in a cookie is not secure due to it's location at client end. Cookie was introduced with first version of Netscape navigator (that was 1.0). 

Advantages

  1. Cookies do not require any server resources since they are stored on the client.

  2. Cookies are easy to implement.

  3. You can configure cookies to expire when the browser session ends (session cookies) or they can exist for a specified length of time on the client computer (persistent cookies).

Disadvantages

  1. Users can delete a cookies.

  2. Users browser can refuse cookies ,so your code has to anticipate that possibility.

  3. Cookies exist as plain text on the client machine and they may pose a possible security risk as anyone can open and tamper with cookies.

.ASPX CODE




<html xmlns="http://www.w3.org/1999/xhtml" > 
<head id="Head1" runat="server">
<title></title>
</head> 

<body> 
<form id="form1" runat="server">
<div> 
<fieldset>
<legend>rdfdf</legend>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Add" Width="70px"
onclick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="View" Width="84px"
onclick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="" Width="138px"></asp:Label> </fieldset> </div> </form> </body> </html>

State Management in ASP.NET

State Management in ASP.NET

State management is the process by which you maintain state and page information over multiple requests for the same or different pages.

Types of State Management

Client – Side State Management

ASP.NET provides various client side state management options like Cookies, Query Strings (URL), Hidden fields, View State and Control state (ASP.NET 2.0).This stores information on the client's computer by embedding the information into a Web page, a uniform resource locator (url), or a cookie. The techniques available to store the state information at the client computer.

a. View State – Asp .Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp .net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

Example of View state

Write code in .aspx  page


<%@ Page Language="C#" AutoEventWireup="true"  
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ViewState</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox runat="server" id="NameField" />
        <asp:Button runat="server" id="SubmitForm" onclick="SubmitForm_Click" 
text="Submit & set name" />
        <asp:Button runat="server" id="RefreshPage" text="Just submit" />
        <br /><br />
        Name retrieved from ViewState: <asp:Label runat="server" id="NameLabel" />
    </form> 
</body>
</html>

.Cs Code


 protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["NameOfUser"] != null)
            NameLabel.Text = ViewState["NameOfUser"].ToString();
        else
            NameLabel.Text = "Not set yet...";
    }
    protected void SubmitForm_Click(object sender, EventArgs e)
    {
        ViewState["NameOfUser"] = NameField.Text;
        NameLabel.Text = NameField.Text;
    }

Advantages

The main advantage of view state is persisting controls properties without any programming and memory will not be occupied on the client system or on the server system.

Disadvantage

The disadvantage can be considered as a lot amount of data transmission between client and server.

  1. Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.

  2. Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.

  3. Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

  4. Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

Various types of application that we can develop in .NET

Various types of application that we can develop in .NET

When you hear the name .NET, it gives a feeling that it is something to do only with internet or networked applications. Even though it is true that .NET provides solid foundation for developing such applications it is possible to create many other types of applications.

Following list will give you an idea about various types of application that we can develop on .NET.

  • ASP.NET Web applications: These include dynamic and data driven browser based applications.

  • Windows Form based applications: These refer to traditional rich client applications.

  • Console applications: These refer to traditional DOS kind of applications like batch scripts.

  • Component Libraries: This refers to components that typically encapsulate some business logic.

  • Windows Custom Controls: As with traditional ActiveX controls, you can develop your own windows controls.

  • Web Custom Controls: The concept of custom controls can be extended to web applications allowing code reuse and modularization.

  • Web services: They are “web callable” functionality available via industry standards like HTTP, XML and SOAP.

What is  Partial Class

The purpose of a partial class is to allow you to textually break up a class declaration into multiple parts, usually parts found in separate files. The motivation for this feature was machine-generated code that is to be extended by the user by adding to it directly. When you draw a form in the forms designer, the designer generates a class for you representing that form. You can then further customize that class by adding more code to it.

By the use of partial Class  you can split the definition into multiple classes by using the partial keyword. When the application is complied, the C# complier will group all the partial classes together and treat them as a single class. There are a couple of good reasons to use partial classes. Programmers can work on different parts of a class without needing to share the same physical file. Also you can separate your application business logic from the designer-generated code.

Example of Partial Class



 Public partial class Employee

{

      public void display()

      {}

}



Public partial class Employee

{

       public void show()

       {}

}

Life Cycle of ASP.NET

Life Cycle of ASP.NET

Page Life Cycle Events

  • Page_Init: The server controls are loaded and initialized from the Web form's view state. it is basically used for initialized the object and control
  • Page_Load:The server controls are loaded in the page object. View state information is available at this point, so this is where you put code to change control settings or display text on the page.
  • Page_PreRender: The application is about to render the page object.
  • Page_Unload: The page is unloaded from memory.
  • Page_Disposed: The page object is released from memory. This is the last event in the life of a page object.
  • Page_Error: An unhandled exception occurs.
  • Page_AbortTransaction: A transaction is aborted.
  • Page_CommitTransaction: A transaction is accepted.
  • Page_DataBinding: A server control on the page binds to a data source. 

Control in ASP.NET

  • HTML  Controls - Traditional HTML tags

  • Web Server Controls - New ASP.NET tags

  • Validation Server Controls - For input validation

HTML Server Controls

HTML server controls are HTML tags understood by the server.

HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a  runat="server" attribute to the HTML element. This attribute indicates that the element should be treated as a server control. The id attribute is added to identify the server control. The id reference can be used to manipulate the server control at run time.

Note: All HTML server controls must be within a <form> tag with the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts.

DESIGN OF HTML CONTROL


<script language="javascript" type="text/javascript">

function Submit1_onclick() { 
alert("click me");


}


</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <input id="Text1" type="text" value="anil" />
  <input id="Submit1" type="submit" value="submit" 
onclick="return Submit1_onclick()" /></div> </form> </body> </html>

Web Server Controls

  • Web server controls are special ASP.NET tags understood by the server.
  • Like HTML server controls, Web server controls are also created on the server and they require a runat="server" attribute to work.
  •  However, Web server controls do not necessarily map to any existing HTML elements and they may represent more complex elements.

The syntax for creating a Web server control is:

<asp:control_name id="some_id" runat="server" />

 

DESIGN OF WEB SERVER CONTROL

.ASPX CODE


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>


</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 246px; background-color: #66FFFF;">
        Name&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />

        <asp:TextBox ID="TextBox2"
            runat="server" ></asp:TextBox>
        <br />
        <br />

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="click me" />
        <br />
        <br />

    </div>
    </form>
</body>
</html>

.CS CODE



protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "wiliam";
        TextBox2.Text = "hello world";
    }

Validation Server Controls

DESIGN OF VALIDATION SERVER CONTROL

Validation server controls are used to validate user-input. If the user-input does not pass validation, it will display an error message to the user.

.ASPX CODE



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>


</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 414px; background-color: #66FFFF;">
        Name&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="TextBox1" ErrorMessage="Blank are not allowed" 
            SetFocusOnError="True"></asp:RequiredFieldValidator>
        <br />
&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox2"
            runat="server" ontextchanged="TextBox2_TextChanged"></asp:TextBox>
        <br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="click me" />
        <br />
        <br />
    </div>
    </form>
</body>
</html>


CS CODE



 protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "123";
        TextBox2.Text = "hello world";
        Response.Write("hi display textbox 1 value"+TextBox1.Text);
    }

Architecture of ASP.NET

Architecture of ASP.NET

                         

  • The configuration of ASP.NET is managed by information stored in XML-format in a configuration file (Web.Config).

  • The cache allows for improved performance of ASP.NET, as the most commonly requested pages would be served from

  • the ASP.NET cache.State management services for ASP.NET are provided by the ASP.NET state service.

  • The .NET Framework provides the Common Language Runtime (CLR) , which compiles and manages the execution of ASP.NET

  • code, and the class libraries, which offer prebuilt programmatic functionality for Web Forms, XML support, and exception handling.

  • ADO.NET provides ASP.NET with connections to databases.

3-Tier Architecture in ASP.NET with C#

3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL).

Presentation Layer (UI)
Presentation layer contains pages like .aspx or windows form where data is presented to the user or input is taken from the user.

Business Access Layer (BAL) or Business Logic Layer
BAL contains business logic, validations or calculations related with the data..

Data Access Layer (DAL)
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating

data (insert, update, delete etc).

Designing 3-Tier Architecture

Data Access Layer (DAL) Code

Code for Data Access Layer


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.OleDb;


public class PersonDAL
{
    
  string connStr = ConfigurationManager.ConnectionStrings
[
"connectionstring"].ToString(); public PersonDAL() { } public int Insert(string name, string address, int age) { OleDbConnection conn = new OleDbConnection(connStr); conn.Open(); OleDbCommand dCmd = new OleDbCommand("insert into insertrecord values
(@P,@q,@r)"
,conn); try { dCmd.Parameters.AddWithValue("@p", name); dCmd.Parameters.AddWithValue("@q", address); dCmd.Parameters.AddWithValue("@r", age); return dCmd.ExecuteNonQuery(); } catch { throw; } finally { dCmd.Dispose(); conn.Close(); conn.Dispose(); } } }

Business Access Layer (BAL) Code

Code for Business Access Layer
 


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public class PersonBAL
{
    public PersonBAL()
    {
    }
    public int Insert(string name, string address, int age)
    {
        PersonDAL pDAL = new PersonDAL();

        try
        {

            return pDAL.Insert(name, address, age);

        }

        catch
        {

            throw;

        }

        finally
        {

           pDAL = null;
        }
    }
}
   

Code for .cs file


using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Lets validate the page first

        if (!Page.IsValid)

            return;

        int intResult = 0;

        PersonBAL pBAL = new PersonBAL();

       // Instantiate the object we have to deal with

        string name = txtname.Text;
        string address = txtaddress.Text;
        int age = Int32.Parse(txtAge.Text);
        try
        {
           intResult = pBAL.Insert(name, address, age);
            if (intResult > 0)

               lblMessage.Text = "New record inserted successfully.";

            else

   lblMessage.Text = "FirstName [<b>" + txtname.Text + "</b>] 
                      alredy exists, try another name";

        }
        catch (Exception ee)
        {

            lblMessage.Text = ee.Message.ToString();

        }

        finally
        {

            pBAL = null;

        }        
    }
}

Presentation Layer

 

Code for .aspx page


<%@ Page Language="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"
Inherits="_Default"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
            height: 215px;
            background-color: #FFFFCC;
        }
        .style2
        {
            width: 271px;
        }
        .style3
        {
            width: 271px;
            height: 44px;
        }
        .style4
        {
            height: 44px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="background-color: #008000; height: 253px;">
    
        <table class="style1">
            <tr>
                <td colspan="2">
                                      ADD RECORDS&nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;&nbsp;&nbsp;&nbsp;Name</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp; 
                    Address&nbsp;</td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Age&nbsp;</td>
                <td class="style4">
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                        Text="Save Record" />
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>   
    </div>
    </form>
</body>
</html>

Introduction to Asp.Net

Introduction of ASP.NET

ASP.NET is the next generation ASP, but it's not an upgraded version of ASP. ASP.NET is an entirely new technology for server-side scripting. ASP.NET is a part of the Microsoft .NET framework, and a powerful tool for creating dynamic and interactive web pages. ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server

  • ASP.NET is a Microsoft Technology.

  • ASP stands for Active Server Pages

  • ASP.NET is a program that runs inside IIS.

  • IIS (Internet Information Services) is Microsoft's Internet server.

  • IIS comes as a free component with Windows servers.

  • IIS is also a part of Windows 2000 and XP Professional.

ASP.NET File

  • An ASP.NET file is just the same as an HTML file

  • An ASP.NET file can contain HTML, XML, and scripts

  • Scripts in an ASP.NET file are executed on the server

  • An ASP.NET file has the file extension ".aspx"

Working of ASP.NET

  • When a browser requests an HTML file, the server returns the file.

  • When a browser requests an ASP.NET file, IIS passes the request to the ASP.NET engine on the server.

  • The ASP.NET engine reads the file, line by line, and executes the scripts in the file.

  • Finally, the ASP.NET file is returned to the browser as plain HTML.

Difference Between ASP and ASP.NET

  1. Code behind in asp. net allows separation of business logic from UI which is not possible in asp.

  2. ASP. Net uses ADO .Net objects which are represented using XML and hence they are lightweight and can travel through firewalls. ASP uses ADO record sets which are binary COM objects heavier than ADO.Net counterparts and cannot travel through firewalls.

  3. ASP.Net supports object oriented programming. ASP is procedural.

  4. ASP.Net is compiled and hence performs better. ASP is pure scripting and hence interpreted at the time of page load.

  5. ASP.Net has caching and exception handling which is not available with ASP.

  6. ASP.NET has better language support, a large set of new controls, XML-based components, and better user   authentication.

  7. ASP.NET provides increased performance by running compiled code.

  8. ASP.NET code is not fully backward compatible with ASP

Advantage of ASP.NET

  1. ASP.NET drastically reduces the amount of code required to build large applications.

  2. With built-in Windows authentication and per-application configuration, your applications are safe and secured.

  3. It provides better performance by taking advantage of early binding, just-in-time compilation, native optimization, and caching services right out of the box.

  4. The ASP.NET framework is complemented by a rich toolbox and designer in the Visual Studio integrated development environment. WYSIWYG editing, drag-and-drop server controls, and automatic deployment are just a few of the features this powerful tool provides.

  5. Provides simplicity as ASP.NET makes it easy to perform common tasks, from simple form submission and client authentication to deployment and site configuration.

  6. The source code and HTML are together therefore ASP.NET pages are easy to maintain and write. Also the source code is executed on the server. This provides a lot of power and flexibility to the web pages.

  7. All the processes are closely monitored and managed by the ASP.NET runtime, so that if process is dead, a new process can be created in its place, which helps keep your application constantly available to handle requests.

  8. It is purely server-side technology so, ASP.NET code executes on the server before it is sent to the browser.

  9. Being language-independent, it allows you to choose the language that best applies to your application or partition your application across many languages.

  10. ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in.

  11. The Web server continuously monitors the pages, components and applications running on it. If it notices any memory leaks, infinite loops, other illegal activities, it immediately destroys those activities and restarts itself.

  12. Easily works with ADO.NET using data-binding and page formatting features. It is an application which runs faster and counters large volumes of users without having performance problems.