Aspnet Applications And State Management

Exlr fH The Assembly directive lets you link components to namespaces that have been imported with the Import directive.

Example:

<%@ Assembly Name="MyAssembly.dll" %>

Another directive you can use in your Global.asax file is the Application directive. The Inherits attribute defines the new application base class. This will need to be a compiled .NET class on your server. You can also specify a friendly name for the application with the Description attribute.

Example

<%@ Application Inherits=" MySampleApp.Object"

Description=

"Sample Description"%>

Untitled - Notepad

File Edit Format Help

'■% @ Import Namespace=|"Svstern.lO"|%>l

<SCRIPT LANGUAGE="C#" RUNAT="Sen/er">

void Appllcation_Start() {

string stringSiteName = "My Lifetime Goals"; Appllcatlon["appllcatlonSlteName"] = stringSiteName;

void Appllcation_End() {

Appllcatlon["appllcatlonSlteName"] ="";

void Sesslon_Start() {

Response.Wrlte("<FONT FACE='Verdana'>Session Start called...<BR/></FONT>");

string stringllserGreetlng = "Welcome to My Lifetime Goals Sesslon["sesslonUserGreetlng"] = stringUserGreetlng;

void Sesslon_End() {

Sesslonf'sesslonUserGreetln'

^H Position the insertion point between the quotation marks (" ") and type the namespace you want to import.

UsinglmportDirectiveGlobalTemplate asax - Notepad

File Edit Format Help

New Ctrl+N

Save Ctrl+S

space-'System.10" %> ■E-"C#" RUNAT-'Server">

File Edit Format Help

New Ctrl+N

Save Ctrl+S

space-'System.10" %> ■E-"C#" RUNAT-'Server">

Click File O Save As to open the dialog box.

~E3 Click 0 to select the folder where you want to store your file.

Type a name for the Web page.

Note: Click the Yes button if you are prompted about replacing the file.

■ The namespace is now declared for all pages on the site.

USING

Was this article helpful?

0 0

Post a comment