You are on page 1of 4

ASP.

NET server controls

They are ‘live’ on the server inside an ASPX page. When the page is requested in the browser , the
server side controls are processed by the ASP.NET runtime- the engine that is responsible for the
receiving and processing requests for ASPX pages.

The controls then emit the client-side HTML code that is appended to the final page output.

It is this HTML code that is eventually end up in the browser where it is used to build up the pages.

So instead of defining the HTMl controls in your pages directly you define an ASP.Net server control with
the following syntax where the italic parts differ for each control.

<asp: TypeofControl ID= “controlName” Runat=”server”/>

This has 2 attributes.

1. ID uniquely identifies a control in the page. so you can program against it.
2. Runat this is mandatory. to indicate that control is live at the server.

*** for non server elements like plain HTMl elements the runat attributes are optional.

Common properties of all controls

Property Descriptiono
Access key Allows you to set a key with wich a control can
be accessed in the client by pressing the
associated letter.
Backcolor,forecolor Allows you to change the color of the
background and text of the control in the
browser.
Bordercolor, Changes the border of the control in the
Borderstyle, browser.
Borderwidth
TabIndex Sets HTML tab index attribute that determines
the order in which users can move through
the controls in the page by pressing the tab
key.
Tool Tip Allows you to set a tool tip for the control in
the browser.
Visible Determines whether the control is sent to the
browser or not.
You should really see this as a server side
visibility setting becase an invisible control is
never sent to the browser at all.
Height,Width
Enabled Determines whether the user can interact
with the control in the browser.

Types of control
1. Standard controls
1.1 simple controls
1.2 list controls
 list box

Bind the control


to a data source

Sets the auto post back property of control. With option checked the control will submit the page it’s contains
in back to the server as soon as the user chooses a new item from the list

 check box list


 radio button list
 bulleted list
1.2.3 Container controls

* place holder

Good thing about this is that it emits no HTML of it’s own to the page. But it lacks design time support

* Panel

This is good because it support the design time

*Multiview

Which can contain one or more <Asp:View> controls

*wizard

Allows you to split up a long page into multiple areas.the Wizard has built-in support for moving from
page to page using Previous, Next and Finish buttons, while multi view must be controlled
programmatically.

Other standard controls

Link button/Image button


Work like normal button
User PostBack to the server

Image and Image Map


Image map allows you to click the hotspots when clicked postsback to the server or navigate to
a different page
Calender
File Upload
Literal,
Renders no additional tag. It displays what you assigned to it

Localise
To use in multilingual websites

Substitute
Allows you to update only parts of the page

Adrotator
Allows you to display random advertisements

Hidden field
XML
Table

ASP.Net state engine

Deeply integrated in the ASP.net runtime

It enables controls to maintain their states across postbacks so their values remain available after the
postback

Controls rely on view state:-

Label,calendar,button

Controls not rely on viewstate:-

Textboxes, checkboxes. Radio button and drop down list

Questions
1. Name the mechanism that enables the server controls to maintain their state
2. How is the ASP.Net runtime able to keep track of control state between postbafcks?
3. Name a difference between <asp: dropdown list> and an <asp:ListBox>
4. What property doyou need to cause a postback to the server when you changed the
checked state of a checkbox in the browser?
5. Many server controls have a common set of properties that affects their looks at
runtime.Name 3 properties that change stryling elements such as color, borders and size.
6. Instead of setting individual control properties like Backcolor and forecolor, it’s better to set
a single CSS-related property.what is the name of this property and what benefit does it
gives to you?

You might also like