Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Book Cover Pure ASP.NET
100377 times
Rated
Read 100,377 times

Contents

Related Categories

ASP.NET Web Forms - Web Form Events

Web Form Events

From the moment a user first requests an ASP.NET Web Form to the moment the server actually sends the response, quite a few events and processes occur. A few of the most important ones are described in the following sections.

A significant number of events occur between the moment a client issues a page request and the moment that the server sends the response. Many of these events will be transparent to you as the developer, and they will involve the compiler, the preprocessors, and the various collections that make up the .NET framework. However, you will need to understand some events because you will likely come across them in your coding escapades. Figure 3.1 shows the events in a life cycle of an ASP.NET request.



Figure 3.1
The life cycle of an ASP.NET request

 

Page Directives

Page directives enable you to set optional metasettings for the compiler when it processes the ASP.NET Web form. You can use page directives to set the default language for the ASP.NET Web form, enable or disable session state, choose to buffer the contents of the page before sending to the client, and make a host of other changes.

Page directives must be located at the very top of an ASP.NET Web Form, before any other code. A page directive is always contained inside <% %> tags and always begins with the @ character. Here is an example of the syntax used for a page directive:

<%@ directive.property = value %>

For example, to turn off session state for a page, you use the following page directive:

<%@ Page EnableSessionState="false"%>

Server-Side Includes

SSIs offer a way to insert the contents of a file into an ASP.NET Web form. Because an SSI is inserted before the page is compiled to IL, you can use an SSI to insert blocks of source code into a page. You can use SSIs to add a copyright notice to the bottom of a page, include a common set of functions, or include any other sort of static content.

The code for an SSI looks like this:

<!-- #include PathType = FileName -->

PathType can be set to either File or Virtual, depending on the type of path being referenced:

  • File sets a relative path from the directory in which the ASP.NET Web Form is located. It is important to note that the file location cannot be in a directory higher on the file tree than the current directory. This prevents a possible breach in a site's security.

  • Virtual enables you to include a file from a virtual path from a virtual directory on the Web server.

Tip
You should not use SSIs to encapsulate site functionality such as site navigation or common site text. ASP.NET offers a solution for these types of situations, called user controls, which are explored in the following section.

 

Comments

  • more help?

    Posted by HardlyNoticable on 23 Aug 2005

    Peter: You are using an alert box. I'm pretty sure that only the exclamation icon is your only option.

    svkoli: I get the following error when I try to use your box:

    CS0122: 'testresults.Button1...

  • Posted by chandrababu on 28 Jul 2005

    Use window.confirm()

  • Posted by VasanthKumar on 28 Jul 2005

    [quote][1]Posted by [b]surendar[/b] on 10 Jan 2005 11:47 PM[/1]
    what the code to create a messagebox in asp using c# language ?
    [/quote]

    http://www.developerfusion.co.uk/show/4700/
    see this.

  • Posted by anshu on 28 Jul 2005

    anyone can please tell me how to create a message box with ok & cancel buttons on a web page using asp.net using code behind ? Actually i am new to .NET. i reqire it urgently.

  • Posted by laney_18_boggs on 24 Jun 2005

    string message = strConn;
    string alertScript = "