Professional Documents
Culture Documents
By
SRIRAM. B
Standard Controls
Label List Box
Literal DropDownList
Localize Check Box
TextBox Check Box List
Button Radio Button
Link Button Radio Button List
Image Button Image
Hyper Link Table
Calendar Panel &Place Holder
Ad Rotator Substitution
Label
This control renders text, or an HTML fragment, on the page. You can change the
displayed text with server-side code.
Using <asp:Label> control, the control uses the Text Attribute to assign the content of
the control.
Instead of Text attribute, you can place the content to be displayed in <asp:Label>
element.
Label1.Text=”Hello World”;
Literal
The Literal control renders static text into a Web page without adding any HTML
elements. You can manipulate the text programmatically with server code.. Unlike
the Label control, the Literal control does not render its content inside <span> tag.
If you want to display static text, you can present it using HTML; you do not need a
Literal control. Use a Literal control only if you need to change the contents in
server code. The Literal control is similar to the Label control, except the Literal
control does not enable you to apply a style to the displayed text.
The “Mode” property enables you to encode HTML content. It accepts the following
values.
PassThrough -> Displays the contents of the control without encoding.
Literal..
Encode -> Displays the contents of the control after HTML encoding the
content.
Transform -> Displays the contents of the control after stripping markup that is
not supported by the requesting device.
If you place some HTML code in the string that is output (<b>Here some text</b>),
the Literal control outputs just that and consuming browser shows the text as bold.
Use the Localize control to reserve a location on a Web page to display localized
text. The Localize control is identical to the Literal control and similar to the Label
control. While the Label control allows you to apply a style to the displayed text, the
Localize control does not.
You can programmatically control the text that is displayed in the Localize control
by setting the Text property, which is inherited from the Literal control.
Localize..
<asp:Localize id="Localize1" runat="server"
meta:resourcekey="Localize1Resource1" Text="Hello World!">
</asp:Localize>
HelloWorld<br />
<br />
<br /> Welcome to ASP.NET
<hr/>
TextBox
The user can enter text and numeric values into the boxes that are displayed. This
control supports input masks that make it suitable for entering passwords or other
sensitive information.
TextChanged –> Raised on the server when the contents of the text box
are changed.
Properties
Autopostback -> Enables you to post the form containing the TextBox
back to the server automatically when the contents of
the textbox is changed.
Method
Focus() -> Enables you to set the initial form focus to the Button Control
Events
Command -> Raised when the button control is clicked. The CommandName &
CommandArgument are passed to this event.
Button..
Properties
This control renders an object that appears as a hyperlink to the user, but behaves
as a button in terms of its programming model.
i.e., Methods,Properties&Events are same like the Button.
The event handler for an Image Control is differ from other button controls, it is
passed to an instance of the ImageClickEventArgs class. It has the following
properties : -
X – The x coordinate relative to the image the user clicked
Y – The y coordinate relative to the image the user clicked
Hyperlink
This control renders an HTML <a> tag, which you can use to link to another Web page.
Unlike LinkButton Control, the HyperLink control does not submit a form to a server.
The HyperLink Control can be used for images as well as text.
Properties
ImageAlign -> Enables you to align image relative to other HTML elements in the
page. Possible values are AbsBottom, AbsMiddle, Baseline,
Bottom, Left, Middle, NotSet, Right, TextTop & Top.
DescriptionUrl -> Enables you to provide the Detailed description of the image.
Calendar
This control renders a calendar that the user can use to view and pick date values.
. <asp:Calendar ID=”Calendar1” Runat=”server” />
Events
DayRender -> Raised as each day is rendered
SelectionChanged -> Raised when a new day, week or month is selected.
VisibleMonthChanged -> Raised when the next or previous month link is clicked.
Properties
<Ad>
<ImageUrl>XMLBook1.gif</ImageUrl>
<NavigateUrl>http://www.Microsoft.com</NavigationUrl>
<AlternateText>Visit Microsoft.com</AlternateText>
<Impressions>50</Impressions>
<Keyword>XML Books</Keyword>
</Ad>
</Advertisements>
AdRotator..
<asp:AdRotator id=”AdRotator1” AdvertisementFile=”MyAds.XML”
KeywordFilter=”XMLBooks” CssClass =”books” Runat=”server” />
Event
AdCreated -> Raised after the AdRotator control selects an advertisement but before
the AdRotator control renders the advertisement.
Properties
NavigationalUrlField, Target,
<asp:ListItem>Mumbai</asp:ListItem>
</asp:ListBox >
<asp:ListItem>Mumbai</asp:ListItem>
</asp:DropDownList >
Check Box
These controls render check boxes with which the user can enter true/false or
yes/no values.
Properties
Method
Focus()
Event
CheckedChanged
Check Box List
It render check box with ListItem used to populate multiple check boxes from
CheckBoxList control.
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
</asp:CheckBoxList>
Properties
In a RadioButtonList, all the buttons are automatically grouped. You can create
individual option buttons in a RadioButtonList control with ListItem controls.
Like CheckBox, RadioButton, DropDownList, you can select only one item at a time
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
</asp:RadioButtonList>
Properties
<asp:TableHeaderCell>First Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Last Name</asp:TableHeaderCell></asp:TableRow>
<asp:TableRow><asp:TableCell>Bill</asp:TableCell>
<asp:TableCell>Gates</asp:TableCell></asp:TableRow>
</asp:Table>
Panel
This control is used as a container for other controls and tags. By grouping
elements within a Panel control you can, for example, hide or show them all in a
single line of code.
Properties
The Scrollbar attribute is Auto, None,Horizontal,Vertical and Both
The Horizontal Align attribute is NotSet, Center, Justify,Left and Right
The directions you can set NotSet, LeftToRight and RightToLeft
Place Holder
This control is used to mark a place in the page. You can use this to easily insert
other controls into the page at a particular place at run time.
PlaceHolder1.Controls.Add(NewLabelControl)
Creates a new instance of a Label control and populates it with a value before it is
added to the PlaceHolder control.
Demo
Session Ends
Exercise
New Web Server Controls in ASP.NET 2.0
Bulleted List
With this control, users can specify a file to upload to the Web server. You must
implement server-side code to handle this upload and store the file.
Properties
Methods
Focus, SaveAs
File Upload Control
File Uploading
Image Map
Similar to the Image control, this control renders an image. However, it also allows
you to create HotSpots within the image, which links to other pages.
The control contains several View controls, each of which can contain HTML
markup or other controls. Only one view is displayed at a time.
You can display a view by using the SetActiveView method of the control.
Multiview
Multiview Control
Hidden Fields
This control can be used to store information in the page that you do not want the
user to see.
<asp:HiddenField ID="HiddenField1" runat="server"
OnValueChanged="HiddenField1_ValueChanged" />
<WizardSteps>
StepType="Complete" OnActivate="WizardStep4_Activate>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
Wizard
Wizard Control
Data Collection
S-S HTML Controls
Demo
Session Ends
Exercise
Relax