A tipical ASPX page include three sections: page derictives, code and page layout.
- Page directives: This section is used to set up the environment which specifies how the page should be processed.
- Code: This section contains code to handel the events that execute in the server based on the ASP.NET page processing model.(.cs for C# and .vb for Visual basic)(This may be in a seperate page or you can specify the code in the same page using the
tag with the attribute runat="server". - Page Layout: The Page layout is written using the HTML. This includes the HTML body, markup and the style information.
Example:
1)
<%@ Page Language="VB" %> <"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!--code--> <script runat="server"> Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Label1.Text = "Hello World!" End Sub
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </div> </form> </body> </html>
Single File VS Code- Behind Pages:
In single file model the compiler generates a new class for the page which inherits the Page Class.
The Code-Behind pages are physically separated from the user interface layout. This makes it easier to work with. The code is stored as a partial class that inherits from the Page class. Simplyfing the maintainance of the page as you do not have to keep page initialization information in a separate partial class as visual studio takes care of it.
0 comments:
Post a Comment