0% found this document useful (0 votes)
2 views27 pages

Asp ppt4

The document provides an overview of ASP.NET directives, explaining their syntax and usage, including directives such as Page, Master, Import, Reference, Control, Register, and Implements. It also describes the ASP.NET Web Page Code Model, detailing the single-file and code-behind page models for managing visual elements and programming logic. Additionally, it introduces ASP.NET Web Forms server controls like Label and TextBox, highlighting their purpose and example syntax.

Uploaded by

veena v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views27 pages

Asp ppt4

The document provides an overview of ASP.NET directives, explaining their syntax and usage, including directives such as Page, Master, Import, Reference, Control, Register, and Implements. It also describes the ASP.NET Web Page Code Model, detailing the single-file and code-behind page models for managing visual elements and programming logic. Additionally, it introduces ASP.NET Web Forms server controls like Label and TextBox, highlighting their purpose and example syntax.

Uploaded by

veena v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

ASP.

NET - Directives
ASP.NET directives are instructions to specify optional settings
How to use the directives in an ASP.NET page
It is not difficult to add a directive to an ASP.NET page. It is
simple to add directives to an ASP.NET page
The syntax for declaring a directive is:

• <%@ directive_name attribute=value %>


See the directive format, it starts with "<%@" and ends
with "%>". The best way is to put the directive at the top of
your page. But you can put a directive anywhere in a page.
One more thing, you can put more than one attribute in a
single directive.
The Page Directive

The Page directive defines the attributes specific


to the page file for the page parser and the
compiler.
The basic syntax of Page directive is:
<%@ Page Language="C#" %>
OR
<%@ Page Language=“VB.NET" %>
The Master Directive
• The Master directive specifies a page file as
being the mater page.
• The basic syntax of sample MasterPage
directive is:
<%@ MasterPage Language="C#“%>
The Import Directive
• The Import directive imports a namespace
into a web page, user control page of
application.
• Example:
• <%@Import Namespace="System.Data"%>
• The Reference Directive
• The Reference directive indicates that another
page or user control should be compiled and
linked to the current page.
• The basic syntax of Reference directive is:
<%@ Reference Page ="somepage.aspx" %>
• The Control Directive
• The control directive is used with the user
controls and appears in the user control files.
• The basic syntax of Control directive is:
• <%@ Control Language=“vb.net“%>
• The Register Directive
• The Register derivative is used for registering
the custom server controls and user controls.
• The basic syntax of Register directive is:

<%@ Register attribute=value %>


• The Implements Directive
• The Implement directive indicates that the
web page, master page or user control page
must implement the specified .Net framework
interface.
• The basic syntax for implements directive is:
• <%@ Implements Interface="interface_name"
%>
ASP.NET Web Page Code Model
An ASP.NET Web page consists of two parts:
1.Visual elements, which include markup, server
controls, and static text.
2.Programming logic for the page, which includes
event handlers and other code.
ASP.NET provides two models for managing the
visual elements and code — the single-file page
model and the code-behind page model. The two
models function the same, and you can use the
same controls and code for both models.
The Single-File Page Model
In the single-file page model, the page's
markup and its programming code are in the
same physical .aspx file. The programming
code is in a script block that contains the
attribute runat="server" to mark it as code
that ASP.NET should execute.
The Code-Behind Page Model

• The code-behind page model allows you to keep


the markup in one file—the .aspx file—and the
programming code in another file. The name of
the code file varies according to what
programming language you are using.
• For example, if you are working with a page
named SamplePage, the markup is in the file
SamplePage.aspx and the code is in a file named
SamplePage.aspx.vb (for Visual Basic),
SamplePage.aspx.cs (for C#), and so on.
ASP.NET Web Forms Server Controls
ASP.NET Web Forms Label
This control is used to display textual information on the web
forms. It is mainly used to create caption for the other controls
like: textbox.
The example is given below.
< asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label>
This control has its own properties that are tabled below.
ASP.NET Web Forms TextBox
This is an input control which is used to take user input. To
create TextBox either we can write code or use the drag and drop
facility of visual studio IDE.
This is server side control, asp provides own tag to create it. The
example is given below.
< asp:TextBoxID="TextBox1" runat="server" ></asp:TextBox>

You might also like