0% found this document useful (0 votes)
16 views4 pages

Web Form and Its Structure

ASP.NET Web Forms are pages used to create user interfaces for web applications, allowing user interaction through controls and server-side code. They consist of design and programming components, support various programming languages, and include features for state management and reusable components. The structure of a Web Form includes directives, server-side code, static text, server controls, and client controls, facilitating both server-side and client-side processing.

Uploaded by

technogamer6521
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)
16 views4 pages

Web Form and Its Structure

ASP.NET Web Forms are pages used to create user interfaces for web applications, allowing user interaction through controls and server-side code. They consist of design and programming components, support various programming languages, and include features for state management and reusable components. The structure of a Web Form includes directives, server-side code, static text, server controls, and client controls, facilitating both server-side and client-side processing.

Uploaded by

technogamer6521
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/ 4

MICROSOFTASP.

NET 25

th

NQ
Helb

Figure 2.1: Output In Web Browser

2.4 WEBFORMS
2.4. An Introduction ToWeb Forms
ASP.NET pages are officially called as "Web Forms".
Aweb form is an ASP.NET page of a web application which is used to create user
interface (U) between the user and web application. The user interacts with the web
application through user interface.
A web form has properties, methods, events of web controls.
Aweb form in ASP.NET can be created with the help of simple text editor softwares
like Notepad, Wordpad etc or by using an IDE software like Visual Studio 2010.
Aweb form in ASP.NET has the extension .aspx.
> A
web form in ASP NET has two main components: one is the design portion (aspx
file) and another one is the programming code behind the web form (embedded in
.aspx file or separate code file with .aspr.vb).
> An ASP.NET page can contain static code ( HTMI/ XHTML)and dynamic code
(ASP.NET server side code).
Dynamiccode which runs on the server can be placed in a page within a block <%
dynamiccode - %>
> To use server-side functionalities in the Web Forms, all ASP.NET server controls
must include the attribute runat="server".

2.4.2 Characteristics of a Web Form


In .NET documentation, Microsoft has outlined the following characteristics of a Web
Form:
>A Web form of your design can run on a specific browser of your choice, or it can run
on any browser and automatically render the browser-compliant HTML.
26 WEB PROGRAMMING USING ASP.NET

>lItis built on the Common Language Runtime, thereby providing amanaged execution
environment, type safety, inheritance, and dynamic compilation.
Itcan be programmed in any CLR-supported language.
Itsupports WYSIWYG editing tools and development tools such as Visual Studio.NET.
2010.
It supports a rich set of controls thatenables you toencapsulate page logic into reusable
components and declaratively handle page events.
t allows for separation between code and content on a page.
It provides a set of state management features that preserves the view state of a page
between requests.
2.4.3 Structure of an ASP.NET Web Form

STRUCTURE OF WEB FORM

Page Directive
<% Page Language ="C#" %>
<html><body>
<form runat="server">
Static Text
Enter Your Name:
Server Control
<asp:TextBox id="txtName" runat="server" /

<input Type="submit"s Client Control


</form>
</body>
<script runat-"server"> Server Side Code

</script>
<script language="javascript">
CClient Side Code
</script>
</html>
Figure 2.2: Structure of Web Form
> The structure of Web form may contain:
A) Directives
B) Server Side Code
C) Static Text
D) Server Side Controls
E) Client controls
A) Directives: used to control the compilation of an
A directive is a statement which is
ASP.NET page.
MICROSOFT ASP.NET 2,
VA directive starts with <*@ and ends with 8>.
VGenerally a directive is placed at the top of the ASP.NET page but it can be
placed anywhere within the page.
V There are several types of directives e.g. page directives, master directives
etc.
Note:- For more information regarding Directives in ASP.NET, see
chapter 12
B) Server-side code:
Server side code is that code which is processed on the server.
V Server-side code can be embedded in an HTML source code which is run by
the server.
The Server side code can be written in any server-side laniguages like
ASP.NET, PHP etc.
) Client-side code:
V Client-Side code is that code which is executed by the web browser of the
client machine.
The client side code is sent to web browser by the web server and executed
by the web browser.
The client side code is written in client side languages like JavaScript, VB
Script etc. JavaScript is the mostly used client side code.
D) Static text
Static text is the text which we write in the web page code file to display on
the web page.
It may be enclosed within tags or it may be outside the tags.
E) Server controls
ASP.NET server side controls are those controls which are processed on the
server.
Some server side controls provide client side script but their processing is
done on the server.
ASP.NET4.0 also provides AJAX enabled server controls. The AJAX enabled
ASP.NET Server Side controls consist of server code and client code that
have been integrated to create rich client behavior.
There are basically four types of ASPNET Server Side Controls:
a. HTML Server Side Controls.
b. Web Server Controls
c. Validation controls.
d. User controls.
server control by adding an
a) A simnple HTML control can be converted to an HTML HTML Server side controls
additional attribute i.e.runat="server" in the HTML control. controls.
contain runat attribute that makes them HTML Server Side
Example: Server Side HTML Control
runat="'server">
<input type="text" size="40" id ="txtName"
28 WEB PROGRAMMING UsING
ASP.NET
D) Web server controls are special ASP.NET Controls that are run on the server. Like
HTML server controls, Web server controls also require a runat="server" attribute to
work. An ASP.NET server side control always begins with asp: which is known as
tag prefix. The ID attribute specifies the unique name of the control. The ControlType
is the type of the control e.g. TextBox, Button etc. The runat attribute specifies that
the control is to be run or processed on the server.)ASP.NET also includes AJAX
controls to produce rich client behavior.
Syntax of ASP.NET server side controls
<asp:ControlType ID="ID Name" runat="server"/>
Example:
<asp:TextBox ID="txtName" runat ="server">
) Validation controls provided by ASP.NET are used to validate the input data entered
by the user before submitting to the server. By validation, we mean an act of
Comparing something to a given set of rules. In ASP.NET, we validate the input
entered by user into a web form. Vaidation controls provided by ASP.NET are:
Required Field Validator, Range Validator, Comparision Validator, Regular Expressiom
Validator, Custom Validator and Validation Summary control.
d) An User control is a part of ASP.NET web page which can be reused by the other
ASP.NET web pages. User controls have an extension .ascx. User controls may not
have <html>, <form>, <body> tags. User controls files are having a control directive
e.g, <%@ Control language= "C# codeFile="MyuC.ascx.cs" Inherits="UC"%> User
controls files do not have a page directive. We can define the user control as a part of
the ASPNET web page which can be reused in any other ASP.NET page. Whenever
we need to use same user interface elements in multiple pages, we can use a User
Control. Similarities between User controls and ASP.NET web page: User Controls
are closely related to ASP.NET pages. UserControl class and the Page class both are
derived from the base Template Control class. They share many same methods,
properties, and events because they both are derived from the same base class ie.
TemplateControl class. User Controls are having extension .ascx but ASP.NET pages
are having extension .aspx. User control can not be called independently; it must be
used in ASP.NET page so that it can be called.
F) Chent controls:
Clent Controls are the controls which are prcessed at the client side by the client web
browser. HTML Controls are the client side controls. HTML CONTROLS are standard
controls which are part of HTML language.

You might also like