0% found this document useful (0 votes)
10 views

Web Forms Server Controls

Visual basics

Uploaded by

Leslie Qwer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Web Forms Server Controls

Visual basics

Uploaded by

Leslie Qwer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

ASP.

NET PROGRAMMING

Module I
ASP.NET Web Forms Server Controls
• ASP.NET provides web forms controls that are used
to create HTML components.
• These controls are categories as server and client
based.
• The following table contains the server controls for
the web forms.
Control Name Applicable Events Description

Label None It is used to display text


on the HTML page.

TextBox TextChanged It is used to create a text


input in the form.
Continue….
Button Click, Command It is used to create a button.

LinkButton Click, Command It is used to create a button


that looks similar to the
hyperlink.

ImageButton Click It is used to create an


imagesButton. Here, an
image works as a Button.

Hyperlink None It is used to create a


hyperlink control that
responds to a click event.
Continue….
DropDownList SelectedIndexChanged It is used to create a
dropdown list
control.

ListBox SelectedIndexChanged It is used to create a


ListBox control like
the HTML control.

DataGrid CancelCommand, It used to create a


EditCommand, grid that is used to
DeleteCommand, show data. We can
ItemCommand, also perform paging,
SelectedIndexChanged, sorting, and
PageIndexChanged, formatting very
SortCommand, easily with this
UpdateCommand, control.
ItemCreated,
ItemDataBound
Continue….
DataList CancelCommand, It is used to create
EditCommand, datalist that is
DeleteCommand, non-tabular and used to
ItemCommand, show data.
SelectedIndexChanged,
UpdateCommand,
ItemCreated,
ItemDataBound

CheckBox CheckedChanged It is used to create


checkbox.
CheckBoxList SelectedIndexChanged It is used to create a
group of check boxes
that all work together.

RadioButton CheckedChanged It is used to create radio


button.
Continue….
RadioButtonList SelectedIndexChanged It is used to create a
group of radio button
controls that all work
together.

Image None It is used to show


image within the page.

Panel None It is used to create a


panel that works as a
container.

PlaceHolder None It is used to set


placeholder for the
control.
Continue…
Calendar SelectionChanged, It is used to create a calendar. We
VisibleMonthChanged, can set the default date, move
DayRender forward and backward etc.

AdRotator AdCreated It allows us to specify a list of ads


to display. Each time the user
re-displays the page.

Table None It is used to create table.

XML None It is used to display XML


documents within the HTML.

Literal None It is like a label in that it displays a


literal, but allows us to create new
literals at runtime and place them
into this control.
ASP.NET Web Forms Label
• This control is used to display textual information on
the web forms. To create Label either we can write
code or use the drag and drop facility of visual
studio IDE.
< asp:LabelID="Label1" runat="server" Text="Label" >
</asp:Label>
Property Description

AccessKey It is used to set keyboard shortcut for the label.

TabIndex The tab order of the control.

BackColor It is used to set background color of the label.

BorderColor It is used to set border color of the label.


Continue…
BorderWidth It is used to set width of border of the label.

Font It is used to set font for the label text.

ForeColor It is used to set color of the label text.

Text It is used to set text to be shown for the label.

ToolTip It displays the text when mouse is over the label.

Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.


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.
< asp:TextBoxID="TextBox1" runat="server" ></asp:TextBox>

Property Description

AccessKey It is used to set keyboard shortcut for the


control.
TabIndex The tab order of the control.

BackColor It is used to set background color of the


control.

BorderColor It is used to set border color of the control.


Continue….
BorderWidth It is used to set width of border of the control.

Font It is used to set font for the control text.

ForeColor It is used to set color of the control text.

Text It is used to set text to be shown for the control.

ToolTip It displays the text when mouse is over the


control.
Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.

MaxLength It is used to set maximum number of characters


that can be entered.
Readonly It is used to make control readonly.
ASP.NET Web Forms Button
• This control is used to perform events. It is also used to
submit client request to the server. To
create Button either we can write code or use the
drag and drop facility of visual studio IDE.
<asp:ButtonID="Button1" runat="server“ Text="Submit" />

Property Description

AccessKey It is used to set keyboard shortcut for the control.


TabIndex The tab order of the control.
BackColor It is used to set background color of the control.
BorderColor It is used to set border color of the control.
BorderWidth It is used to set width of border of the control.
Continue….

Font It is used to set font for the control text.

ForeColor It is used to set color of the control text.

Text It is used to set text to be shown for the control.

ToolTip It displays the text when mouse is over the control.

Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.


ASP.NET Web Forms HyperLink
• It is a control that is used to create a hyperlink. It
responds to a click event. We can use it to refer any
web page on the server.
• To create HyperLink either we can write code or use
the drag and drop facility of visual studio IDE.

< asp:HyperLinkID="HyperLink1" runat="server"


Text="JavaTpoint" NavigateUrl="www.javatpoint.com"
>
</asp:HyperLink>
Continue….
Property Description

AccessKey It is used to set keyboard shortcut for the


control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the
control.
BorderColor It is used to set border color of the control.

BorderWidth It is used to set width of border of the control.

Font It is used to set font for the control text.

ForeColor It is used to set color of the control text.

Text It is used to set text to be shown for the


control.
Continue….
ToolTip It displays the text when mouse is over
the control.

Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.

NavigateUrl It is used to set navigate URL.

Target Target frame for the navigate url.


ASP.NET Web Forms RadioButton
• It is an input control which is used to takes
input from the user.
• It allows user to select a choice from the
group of choices.
• To create RadioButton we can drag it from
the toolbox of visual studio.
• This is a server side control and ASP.NET
provides own tag to create it.

< asp:RadioButtonID="RadioButton1" runat="server"


Text="Male" GroupName="gender"/>
Continue….
Property Description
AccessKey It is used to set keyboard shortcut for the control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the control.
BorderColor It is used to set border color of the control.
BorderWidth It is used to set width of border of the control.
Font It is used to set font for the control text.
ForeColor It is used to set color of the control text.
Text It is used to set text to be shown for the control.
ToolTip It displays the text when mouse is over the
control.
Visible To set visibility of control on the form.
Height It is used to set height of the control.
Width It is used to set width of the control.
GroupName It is used to set name of the radio button group.
ASP.NET Web Forms Calendar
• It is used to display selectable date in a
calendar. It also shows data associated with
specific date. This control displays a calendar
through which users can move to any day in
any year.
• We can also set Selected Date property that
shows specified date in the calendar.
• To create Calendar we can drag it from the
toolbox of visual studio.
< asp:CalendarID="Calendar1" runat="server"
SelectedDate="2017-06-15" > </asp:Calendar>
Continue…
Property Description
AccessKey It is used to set keyboard shortcut for the
control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the control.

BorderColor It is used to set border color of the control.

BorderWidth It is used to set width of border of the control.

Font It is used to set font for the control text.

ForeColor It is used to set color of the control text.

Text It is used to set text to be shown for the control.

ToolTip It displays the text when mouse is over the


control.
Continue….
Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.

NextMonth Text It is used to set text for the next month


button.
TitleFormat It sets format for month title in header.

DayHeaderStyle It is used to set style for the day header


row.
DayStyle It is used to apply style to days.

NextPrevStyle It is used to apply style to the month


navigation buttons.
ASP.NET Web Forms CheckBox
• It is used to get multiple inputs from the user.
It allows user to select choices from the set of
choices.
• It takes user input in yes or no format. It is
useful when we want multiple choices from
the user.
• To create CheckBox we can drag it from the
toolbox in visual studio.

< asp:CheckBox ID="CheckBox2" runat="server"


Text="J2EE"/>
Continue…
Property Description
AccessKey It is used to set keyboard shortcut for the control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the control.
BorderColor It is used to set border color of the control.
BorderWidth It is used to set width of border of the control.
Font It is used to set font for the control text.
ForeColor It is used to set color of the control text.
Text It is used to set text to be shown for the control.
ToolTip It displays the text when mouse is over the control.
Visible To set visibility of control on the form.
Height It is used to set height of the control.
Width It is used to set width of the control.
Checked It is used to set check state of the control either true or
false.
ASP.NET LinkButton
• It is a server web control that acts as a hyperlink. It is
used to display a hyperlink-style button control on the
web page. ASP.NET provides a tag to create
LinkButton and has following syntax.

<asp:LinkButton ID="LinkButton1" runat="server" >


javapoint</asp:LinkButton>
ASP.NET Web Forms FileUpload
• It is an input controller which is used to upload file to
the server. It creates a browse button on the form
that pop up a window to select the file from the
local machine.
• To implement FileUpload we can drag it from the
toolbox in visual studio.
< asp:FileUpload ID="FileUpload1" runat="server"/>
Property Description

AccessKey It is used to set keyboard shortcut for the


control.
TabIndex The tab order of the control.
BackColor It is used to set background color of the
control.
BorderColor It is used to set border color of the control.
Continue…
Font It is used to set font for the control text.

ForeColor It is used to set color of the control text.

Text It is used to set text to be shown for the control.

ToolTip It displays the text when mouse is over the control.

Visible To set visibility of control on the form.

Height It is used to set height of the control.

Width It is used to set width of the control.

AllowMultiple It is used to allow upload multiple files by setting true


or false
ASP.NET Upload Multiple Files
• ASP.NET FileUpload control provides
AllowMultiple property to upload multiple
files to the server. This property takes either
true or false value.

• The <asp:FileUpload> tag is used to create a


browse button that allows us to upload file.
ASP.NET Download File
• ASP.NET provides implicit
object Response and its methods to
download file from the server.
• We can use these methods in our
application to add a feature of
downloading file from the server to the local
machine.
ASP.NET Session
• In ASP.NET session is a state that is used to store
and retrieve values of a user.
• It helps to identify requests from the same
browser during a time period (session). It is used
to store value for the particular time session. By
default, ASP.NET session state is enabled for all
ASP.NET applications.
• Each created session is stored
in SessionStateItemCollection object. We can
get current session value by
using Session property of Page object.
ASP.NET Cookie
• ASP.NET Cookie is a small bit of text that is used to
store user-specific information. This information can
be read by the web application whenever user visits
the site.
• When a user requests for a web page, web server
sends not just a page, but also a cookie containing
the date and time. This cookie stores in a folder on
the user's hard disk.
• When the user requests for the web page again,
browser looks on the hard drive for the cookie
associated with the web page. Browser stores
separate cookie for each different sites user visited.
• The Cookie is limited to small size and can be used
to store only 4 KB (4096 Bytes) text.
Continue….
• There are two ways to store cookies in
ASP.NET application.
o Cookies collection
o HttpCookie
o We can add Cookie either to Cookies
collection or by creating instance of
HttpCookie class. both work same except
that HttpCookie require Cookie name as
part of the constructor.
ASP.NET DropDownList
• The DropDownList is a web server control
which is used to create an HTML Select
component.
• It allows us to select an option from the
dropdown list.
• It can contain any number of items
• ASP.NET provides a tag to create
DropDownList for web application.
Continue….
• Syntax of DropDownList tag.
<asp:DropDownList id="DropDownList1" runat="server"
DataSource="<% databindingexpression %>"
DataTextField="DataSourceField"
DataValueField="DataSourceField"
AutoPostBack="True|False"
OnSelectedIndexChanged="OnSelectedIndexC
hangedMethod">

<asp:ListItem value="value" selected="True|False">


Text
</asp:ListItem>
</asp:DropDownList>
ASP.NET DataList
• The ASP.NET DataList control is a light weight
server side control that works as a container
for data items.
• It is used to display data into a list format to
the web pages.
• It displays data from the data source.
• The data source can be either a DataTable
or a table from database.
ASP.NET DataGrid
• .NET Framework provides DataGrid control
to display data on the web page.
• It was introduced in .NET 1.0 and now has
been deprecated.
• DataGrid is used to display data in scrollable
grid.
• It requires data source to populate data in
the grid.
• It is a server side control and can be
dragged from the toolbox to the web form.
• Data Source for the DataGrid can be either
a DataTable or a database.

You might also like