|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionASP.NET supports two methods to author pages:
In-line code is code that is embedded directly within the ASP.NET page. Code-behind refers to code for your ASP.NET page that is contained within a separate class file. This allows a clean separation of your HTML from your presentation logic. When we use Microsoft Visual Studio .NET to create ASP.NET Web Forms, code-behind pages are the default method. In addition, Visual Studio .NET automatically performs precompilation for us when we build our solution. A little bit of backgroundDirectives in ASP.NET control the settings and properties of page and user control compilers. They can be included anywhere on a page, although it is standard to place them at the beginning. Directives are used in both .aspx files (ASP.NET pages) and .ascx files (user control pages). ASP.NET pages actually support eight different directives.
Page directives are the most commonly used directives, and are used to edit a wide variety of settings that control how the page parser and page compiler work. The following is a list of some of the more commonly used page directive attributes in ASP.NET. @ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="TestWebApp.WebForm1"
Note: In the above case, ASP.NET compiles the code-behind page on the fly. We have to note that this compilation step only occurs when the code-behind file is updated. Whether the file has been updated or not, well this is detected through a timestamp change. To get to the Real ThingThe We can specify the default value of the
The value of the <configuration> <system.web> <pages autoEventWireup="true|false"
/> </system.web> </configuration>
If you make these changes in the Machine.config file, the changes affect all ASP.NET Web Forms on the computer. If you make these changes in the Web.config file, the changes affect only the application that the file belongs to. However, to make changes in the individual Web Form Only, we have to add the Check out the CodeWhen we create a new ASP.NET Web Application in Visual Studio .NET, as mentioned earlier, by default, the value of the this.Load += new System.EventHandler(this.Page_Load);
The best way to see the working of this attribute would be:
On running the application, you will get the message We are in Page_Load() [hereafter referred to as message]. Note: this is in the default case where the attribute is set to Now try commenting the event handler code for the Now with the event handler code for the Reason: In the case where A thing to be kept in mind is that the Performance IssuesWe must not set the value of the CreditsThe whole thing was really simple but I just thought of posting it online; hope it helps someone. To give credit to where it is due. Most of the information was garnered from different places on the net. I've just complied them together and added a bit of my own to help folks along their way. I was also able to find an article related to this in MSDN Online (Article ID: 317690) but for VB.NET.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||