Professional Documents
Culture Documents
US05CBCA21 Advanced Web Development Technology
US05CBCA21 Advanced Web Development Technology
Web Server Controls: Button, Image Button, Link Button, Textbox, Hyperlink,
ImageMap control (Creating Hotspots),CheckBox and RadioButton, CheckBoxList,
RadioButtonList, ListBox, DropdownList
Rich Controls: Calendar, Adrotator control (showing advertisement from XML file
and Database), FileUpload control
Using Navigation Controls: TreeView, SiteMapPath, Menu, Creating sitemap file for
navigation Designing Master page
1. Button
The Button is an asp.net web server control. 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. We can display a simple push button
on a web page by adding button control on asp.net web page.
1. Simple Push Button: Simple Push Button displays text on a button control.
2. Link Button: Link button displays text that looks like a link or hyperlink.
3. Image Button: Image Button displays an image on a button control.
These entire three buttons has main two events Click and Command events. By default in
asp.net button has click events.
This is a server side control and asp provides own tag to create it. The example is given below.
Server renders it as the HTML control and produces the following code to the browser.
This control has its own properties that are tabled below.
Property Description
Use of ImageButton control is to display an image that responds to mouse clicks. Both the
Click and Command events are raised when the ImageButton control is clicked. You
can use the OnCommand event handler to make the ImageButton control behave like a
Command button.
This is a server side control and asp provides own tag to create it.
<asp:ImageButton ID=”ImageButton1″ runat=”server” />
This control has its own properties that are tabled below.
Property Description
3. Link Button
Property Description
4. Textbox
Textbox control is most usable web server control in asp.net. TextBox control is a
rectangular box which is used to take user to input. In simple word the TextBox is a place
where user can input some text on asp.net web form. To use TextBox on page we can write
code or just drag and drop from toolbox. This is server side control, asp provides own tag to
create it. The example is given below.
< asp:TextBoxID="TextBox1" runat="server" ></asp:TextBox>
Server renders it as the HTML control and produces the following code to the browser.
Properties Description
5. Hyperlink
ID Identification name of textbox control.
This is a server side control and ASP.NET provides own tag to create it. The example is
given below.
< asp:HyperLinkID="HyperLink1" runat="server" Text="JavaTpoint" NavigateUrl="www.javatpoint.com"
></asp:HyperLink>
Server renders it as the HTML control and produces the following code to the browser.
Property Description
6. ImageMap Control
The ImageMap control in ASP.NET 2.0 and onward versions can be used to create an
image that contains defined hot spot regions. When a user clicks a hot spot region,
the control can either generate a post back to the server or navigate to a specified URL.
There are three kinds of hot spot regions defined in ImageMap control.
• RectangleHotSpot
• CircleHotSpot
• PolygonHotSpot
The RectangleHotSpot defines rectangular hot spot regions. The CircleHotSpotdefines circle-
shaped ones and the PolygonHotSpot is used for irregularly shaped hot spot area.
This control has its own properties that are tabled below.
Property Description
HotSpotMode PostBack/Navigate .... When Navigate, the user is navigated to a different URL. In
case of PostBack, the page is posted back to the server.
OnClick Attach a server side event that fires after clicking on image when HostSpotMode
is PostBack.
PostBackValue You can access it in the server side click event through ImageMapEventArgs. (eg.
e.PostBackValue)
7. 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.
This is a server side control and ASP.NET provides own tag to create it. The example is given
below.
Server renders it as the HTML control and produces the following code to the browser.
This control has its own properties that are tabled below.
Property Description
CausesValidation true/false. If true, Form is validated if Validation control has been used in the
form.
ValidationGroup Used to put a checkbox under a particular validation group. It is used when
you have many set of form controls and by clicking a paricular button you
want to validate a particular set of controls only.
8. Radio Button
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.
This is a server side control and ASP.NET provides own tag to create it. The example is given
below.
Server renders it as the HTML control and produces the following code to the browser.
Property Description
AutoPostBack Form is automatically posted back when Radio button selection is changed.
CausesValidation true/false. If true, Form is validated if Validation control has been used in the
form.
OnCheckedChanged Fires when Radio button selection changes. This works only
if AutoPostBack property is set to true.
ValidationGroup Used to put a radio button under a particular validation group. It is used
when you have many set of form controls and by clicking a paricular button
you want to validate a particular set of controls only.
GroupName It is used a group a set of radion buttons so only one of them can be
selected at a time.
9. ChechkboxList
CheckBoxList control is a single control that groups a collection of checkable list items,
Property Description
DataTextField Name of the data source field to supply the text of the items. (No need
to set when you are adding items directly into .aspx page.)
DataValueField Name of the data source field to supply the value of the items. (No
need to set when you are adding items directly into .aspx page.)
DataSourceID ID of the datasource component to provide data. (Only used when you
have any DataSource component on the page, like SqlDataSource,
AccessDataSource etc.)
DataSource The datasource that populates the items in the checkboxlist box.
(Generally used when you are dynamically generating the items from
Database.)
AutoPostBack true/false. If true, the form is automatically posted back to the server
when user click any of the checkbox. It will also
fire OnSelectedIndexChanged method.
AppendDataBoundItems true/false. If true, the statically added item (added from .aspx page) is
maintained when adding items dynamically (from code behind file) or
items are cleared.
OnSelectedIndexChanged Method name that fires when user click any of the checkbox in the list.
(Fires only when AutoPostBack=true.)
RepeatLayout table/flow. Gets or Sets the layout of the chekboxes when rendered to
the page.
RepeatColumns Gets or Sets the no. of columns to display when the control is
rendered.
RepeatDirection Horizontal/Vertical. Gets or Sets the the value to indicate whether the
control will be rendered horizontally or vertically.
10. RadioButtonList
Note: RadioButtonList controls supports the same set of properties as the CheckBoxList
control does.
11. ListBox
ListBox control is an asp.net web server control. ListBox control used to store the multiple
items and allow user to select multiple item from listbox control. In a ListBox control there is
a SelectionMode property to change the mode of section from single to multiple. By
default listbox control selection mode is single if you want to select multiple items from
listbox, then just change the SelectionMode property to multiple.
Property Description
SelectedValue Get the value of the Selected item from the dropdown box.
SelectedIndex Gets or Sets the index of the selected item in the dropdown box.
DataTextField Name of the data source field to supply the text of the items.
DataValueField Name of the data source field to supply the value of the items.
DataSourceID ID of the datasource component to provide data.
DataSource The datasource that populates the items in the listbox box.
AutoPostBack true or false. If true, the form is automatically posted back to the server
when user changes the dropdown list selection.
AppendDataBoundItems true or false. If true, the statically added item (added from .aspx page)
is maintained when adding items dynamically (from code behind file)
or items are cleared.
OnSelectedIndexChanged Method name that fires when user changes the selection of the
dropdown box. (Fires only when AutoPostBack=true.)
12. DropDownList
The DropDownList control is asp.net web server control. We can use dropdownlist control for
hold group of items. The dropdownlist control is used to store the multiple items and allow
user to select only one item from it.The dropdownlist control is also known as combo box
control. In dropdownlist control we can store multiple items but we can select only one item at a
time, that’s why it is also known as Single Row Selection Box.
Property Description
SelectedValue Get the value of the Selected item from the dropdown box.
SelectedIndex Gets or Sets the index of the selected item in the dropdown box.
DataTextField Name of the data source field to supply the text of the items.
DataValueField Name of the data source field to supply the value of the items.
DataSource The datasource that populates the items in the listbox box.
AutoPostBack true or false. If true, the form is automatically posted back to the server
when user changes the dropdown list selection. It will also
fire OnSelectedIndexChanged method.
AppendDataBoundItems true or false. If true, the statically added item (added from .aspx page)
is maintained when adding items dynamically (from code behind file)
or items are cleared.
OnSelectedIndexChanged Method name that fires when user changes the selection of the
dropdown box. (Fires only when AutoPostBack=true.)
Rich Controls:
ASP.NET - Calendars
The calendar control is a functionally rich web control, which provides the following capabilities:
Calendar controls allow the users to select a single day, a week, or an entire month. This is done by using
the SelectionMode property. This property has the following values:
When the selection mode is set to the value DayWeekMonth, an extra column with the > symbol appears
for selecting the week, and a >> symbol appears to the left of the days name for selecting the month.
Example
The following example demonstrates selecting a date and displays the date in a label:
The content file code is as follows:
<head runat="server">
<title>
Untitled Page
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3> Your Birthday:</h3>
<asp:Calendar ID="Calendar1" runat="server
SelectionMode="DayWeekMonth"
onselectionchanged="Calendar1_SelectionChanged">
</asp:Calendar>
</div>
</form>
</body>
</html>
AdRotator Control:
The AdRotator is one of the rich web server control of asp.net. AdRotator control is used
to display a sequence of advertisement images as per given priority of image.
The AdRotator control randomly selects banner graphics from a list, which is specified in an
external XML schedule file. This external XML schedule file is called the advertisement file.
The AdRotator control allows you to specify the advertisement file and the type of window that the
link should follow in the AdvertisementFile and the Target property respectively.
In a Adrotator control images will be changed each time while refreshing the web page.
Like all XML files, the advertisement file needs to be a structured text file with well-defined tags
delineating the data. There are the following standard XML elements that are commonly used in
the advertisement file:
Properties and Events of the AdRotator Class
The AdRotator class is derived from the WebControl class and inherits its properties. Apart from
those, the AdRotator class has the following properties:
Following are the important events of the AdRotator class:
The ads.xml file and the image files should be located in the root directory of the web site.
Try to execute the above application and observe that each time the page is reloaded, the ad is
changed.
step 3 – Drag and drop AdRotator Control on web page from toolbox.
step 4 – go to Add New Item –> Add New XML File in project for write advertisement detail.
step 5 – Assign XML File to AdvertisementFile Property of AdRotator control.
Now, Add new XML file by going to add new item menu.
Select XML file, assign any name for xml file and click Add button to add new xml file.
write below code for advertisement in xml file
The XML file contain the advertisement information.
ImageUrl describe the path of image which is display in adrotator.
The FileUpload class is derived from the WebControl class, and inherits all its members. Apart from those,
the FileUpload class has the following read-only properties:
The posted file is encapsulated in an object of type HttpPostedFile, which could be accessed
through the PostedFile property of the FileUpload class.
The HttpPostedFile class has the following frequently used properties:
Example
The following example demonstrates the FileUpload control and its properties. The form has a
FileUpload control along with a save button and a label control for displaying the file name, file
type, and file length.
In the design view, the form looks as follows:
<body>
<form id="form1" runat="server">
<div>
<h3> File Upload:</h3>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br /><br />
<asp:Button ID="btnsave" runat="server" onclick="btnsave_Click"
Text="Save" style="width:85px" />
<br /><br />
<asp:Label ID="lblmessage" runat="server" />
</div>
</form>
</body>
if (FileUpload1.HasFile)
{
try
{
sb.AppendFormat(" Uploading file: {0}", FileUpload1.FileName);
1) Panel control
2) PlaceHolder control
1) Panel Control:
The Panel Web server control provides a container control in an ASP.NET Web page that user can use as a parent for
static text and for other controls.
User can use the Panel control as a container for other controls.
Properties Description
BackImageUrl Specifies a URL to an image file to display as a background for this control.
GroupingText Title of the Panel. The text of group box around this control's contents.
HorizontalAlign Specifies the horizontal alignment of the content. Legal values are :
1) Center
2) Justify
3) Left
4) NotSet
5) Right
Scrollbar The appearance of scrollbars for the panel.
Wrap A Boolean value that specifies whether the content should wrap or not.
2) PlaceHolder Control:
➢ The PlaceHolder control allows user to place an empty container control in the page and then dynamically to add
child elements to it at run time.
➢ It does not have any visible output and is used as a place holder when we add controls at run time.
➢ The placeholder control saves a spot for you to programmatically add or remove controls.
➢ User can add or remove as many controls as you want to the placeholder control.
➢ Use the Add method to add controls to the placeholder and remove method to remove them.
You’ve already learned simple ways to send a website visitor from one page to another. For
example, you can add HTML links (or HyperLink controls) to your page to let users surf through
your site. If you want to perform page navigation in response to another action, you can call the
Response.Redirect() method or the Server.Transfer() method in your code. But in professional
web applications, the navigation requirements are more intensive. These applications need a
system that allows users to surf through a hierarchy of pages, without forcing you to write the
same tedious navigation code in every page.
Site Maps
• A way to define the navigational structure of your website. This part is the XML site map,
which is (by default) stored in a file.
• A convenient way to read the information in the site map file and convert it to an object
model. The SiteMapDataSource control and the XmlSiteMapProvider perform this part.
• A way to use the site map information to display the user’s current position and give the user
the ability to easily move from one place to another. This part takes place through the
navigation controls you bind to the SiteMapDataSource control, which can include
breadcrumb links, lists, menus, and trees.
You can customize or extend each of these ingredients separately. For example, if you want to
change the appearance of your navigation controls, you simply need to bind different controls to
the SiteMapDataSource. On the other hand, if you want to read site map information from a
different type of file or from a different location, you need to change your site map provider.
You can create it in Visual Studio by right on Website ➤ Add New Item and then choosing the
Site Map option.
Every Web.sitemap file begins by declaring the <siteMap> element and ends by closing that
element. You place the actual site map information between the start and end tags
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
.......
…….
…….
</siteMap>
• Namely, you need to supply the title of the page (which appears in the navigation
controls),
• a description (which you may or may not choose to use),
• the URL (the link for the page).
You add these three pieces of information using three attributes. The attributes are named title,
description, and url, as shown here:
Here’s a complete, valid site map file that uses this page to define a website with exactly one
page:
</siteMapNode>
</siteMap>
Site maps don’t consist of simple lists of pages. Instead, they divide pages into groups. To
represent this in a site map file, you place one <siteMapNode> inside another. Instead of using
the empty element syntax shown previously, you’ll need to split your <siteMapNode> element
into a start tag and an end tag:
<?xml version="1.0" encoding="utf-8" ?>
</siteMapNode>
</siteMap>
When you show this part of the site map in a web page, the Products node will appear as
ordinary text, not a clickable link.
To bind the site Map to the page , add the SiteMapDataSource control to your page. You can
drag and drop it from the Data tab of the Toolbox. It creates a tag like this:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
The SiteMapDataSource control appears as a gray box on your page in Visual Studio, but
The last step is to add controls that are linked to the SiteMapDataSource
TreeView: The TreeView displays a “tree” of grouped links that shows your whole site map at a
look.
Menu: The Menu displays a multilevel menu. By default, you’ll see only the first level, but other
levels pop up when you move the mouse over the subheadings.
SiteMapPath: The SiteMapPath is the simplest navigation control—it displays the full path you
need to take through the site map to get to the current page. For example, it might show
To connect a control to the SiteMapDataSource, you simply need to set its DataSourceIDproperty
to match the name of the SiteMapDataSource.
For example, if you added a TreeView, you should tweak the tag so it looks like this:
For Menu
Binding a Master Page to a Site Map
Website navigation works best when combined with another ASP.NET feature—master pages.
That’s because you’ll usually want to show the same navigation controls on every page. The
easiest way to do this is to create a master page that includes the SiteMapDataSource and the
navigation controls. You can then reuse this template for every other page on your site.
Here’s how you might define a basic structure in your master page that puts navigation controls
on the left:
<html>
<head runat="server">
<title>Navigation Test</title>
</head>
<body>
<table>
<tr>
</td>
</tr>
</table>
</form>
</body>
</html>
Imagine you want to have a dealer section and an employee section on your website. You
might split this into two structures and define them both under different branches in the same
url="~/default_dealer.aspx">
...
</siteMapNode>
url="~/default_employee.aspx">
...
</siteMapNode>
</siteMapNode>
</siteMap>
To bind the SiteMapDataSource to the dealer view (which starts at the Dealer Home page),
You can even make your life easier by breaking a single site map into separate files using
</siteMapNode>
</siteMap>
Property Description
ParentNode Returns the node one level up in the navigation hierarchy, which contains
the
ChildNodes Provides a collection of all the child nodes. You can check the HasChildNodes
PreviousSibling Returns the previous node that’s at the same level (or a null reference if no
such
node exists).
NextSibling Returns the next node that’s at the same level (or a null reference if no such
node exists).
To see this in action, consider the following code, which configures two labels on a page to show
the heading and description information retrieved from the current node:
lblHead.Text = SiteMap.CurrentNode.Title
lblDescription.Text = SiteMap.CurrentNode.Description
End Sub
If you’re using master pages, you could place this code in the code-behind for your master page,
so that every page is assigned its title from the site map.
The next example is a little more ambitious. It implements a Previous/Next set of links, allowing
the user to traverse an entire set of subnodes. The code checks for the existence of sibling nodes,
and if there aren’t any in the required position, it simply hides the links:
lnkNext.NavigateUrl = SiteMap.CurrentNode.NextSibling.Url
lnkNext.Visible = True
Else
lnkNext.Visible = False
End If
End Sub
page. The second picture shows how this link disappears when you navigate to product2.aspx
(either by clicking the Next link or the RevoAnalyze link in the TreeView).
Mapping URLs
You define URL mapping in the <urlMappings> section of the web.config file. You supply
two pieces of information—the request URL (as the attribute url) and the new destination URL
<configuration>
<system.web>
<urlMappings enabled="true">
<add url="~/category.aspx" mappedUrl="~/default.aspx?category=default" />
</urlMappings>
...
…..
…..
</system.web>
</configuration>
The TreeView shows the available pages, but it doesn’t indicate where you’re currently
positioned.
To solve this problem, it’s common to use the TreeView in conjunction with the SiteMapPath
control. Because the SiteMapPath is always used for displaying navigational information (unlike
the TreeView, which can also show other types of data), you don’t even need to explicitly link it to
the SiteMapDataSource:
The SiteMapPath provides breadcrumb navigation, which means it shows the user’s current
location and allows the user to navigate up the hierarchy to a higher level using links.
Following Figure shows an example with a SiteMapPath control when the user is on the
product1.aspx page. Using the SiteMapPath control, the user can return to the default.aspx
page.
Breadcrumb navigation with SiteMapPath
Property Description
ShowToolTips Set this to False if you don’t want the description text to
appear when the user hovers over a part of the site map path.
ParentLevelsDisplayed This sets the maximum number of levels above the current
page that will be shown at once. By default, this setting is -1,
which means all levels will be shown
RenderCurrentNodeAsLink If True, the portion of the page that indicates the current page
is turned into a clickable link. By default, this is False
because the user is already at the current page.
PathSeparator This indicates the characters that will be placed between each
level in the path. The default is the greater-than symbol (>).
Another common path separator is the colon (:).
NodeStyle NodeTemplate All parts of the path except the root and
current node
Imagine you want to change how the current node is displayed so that it’s shown in italics.
To get the name of the current node, you need to write a data-binding expression that retrieves
the title.
This data-binding expression is bracketed between <%# and %> characters and uses a method
named Eval() to retrieve information from a SiteMapNode object that represents a page.
<CurrentNodeTemplate>
</CurrentNodeTemplate>
</asp:SiteMapPath>
Data binding also gives you the ability to retrieve other information from the site map node, such
as the description. Consider the following example:
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
<PathSeparatorTemplate>
</PathSeparatorTemplate>
<RootNodeTemplate>
<b>Root</b>
</RootNodeTemplate>
<CurrentNodeTemplate>
</CurrentNodeTemplate>
</asp:SiteMapPath>
becomes a link that, when clicked, takes the user to the new page. If you hover over a link, you’ll
TreeView Properties
TreeView Styles
Styles are represented by the TreeNodeStyle class, which derives from the more conventional
Style class.
Property Description
ImageUrl The URL for the image shown next to the node.
NodeSpacing The space (in pixels) between the current node and the node
above and below.
The space (in pixels) between the top and bottom of the node
VerticalPadding
text and border around the text.
HorizontalPadding The space (in pixels) between the left and right of the node text and
border around the text.
The space (in pixels) between the last child node of an expanded
ChildNodesPadding parent node and the following node (for example, between the
Investing and Products nodes in above (sitemap template) Figure ).
The TreeView allows you to individually control the styles for types of nodes—for example, root
nodes, nodes that contain other nodes, selected nodes, and so on. Table lists different TreeView
styles and explains what nodes they affect.
Property Description
NodeStyle Applies to all nodes. The other styles may override some or
all of the details that are specified in the NodeStyle.
RootNodeStyle Applies only to the first-level (root) node.
Applies to any node that contains other nodes, except root
ParentNodeStyle
nodes.
Applies to any node that doesn’t contain child nodes and
LeafNodeStyle
isn’t a root node.
SelectedNodeStyle Applies to the currently selected node.
HoverNodeStyle Applies to the node the user is hovering over with the
mouse. These settings are applied only in up-level clients
that support the necessary dynamic script.
For example
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:TreeView>
To try the Menu control, remove the TreeView from your master page, and add the following
• The Menu displays a single submenu. The TreeView can expand an arbitrary number of
node branches at a time.
• The Menu displays a root level of links in the page. All other items are displayed using fly-
out menus that appear over any other content on the page. The TreeView shows all its
items inline in the page.
• The Menu supports templates. The TreeView does not. (Menu templates are discussed
later in this section.)
• The TreeView supports check boxes for any node. The Menu does not.
• The Menu supports horizontal and vertical layouts, depending on the Orientation
property. The TreeView supports only vertical layout.
Menu Styles
The Menu supports defining different menu styles for different menu levels.
Following Figure shows the menu with StaticDisplayLevels set to 2 (and some styles applied
through the Auto Format link).
Master Page:
➢ MasterPages allow user to create a consistent look and behavior for all the pages (or group of pages) in your
web application.
➢ MasterPage means not Homepage.
➢ MasterPage support was one of the most popular features introduced with ASP.NET 2.0.
➢ A MasterPage provides a template for other pages, with shared layout and functionality.
➢ If user wants to display standard header, footer and menu in each page of the website, then user can create the
standard header, footer and menu in a MasterPage.
➢ Master pages help us to build consistent and maintainable user interfaces.
➢ They allow user to layout a page once and use it over and over.
➢ The master page defines placeholders for the content, which can be overridden by content pages. The output
result is a combination of the master page and the content page.
➢ The content page contains the content which user wants to display.
Characteristics:
➢ A Masterpage needs to specify both the parts common to all pages and the parts that are customizable.
➢ Items you add to the master page appear on all pages that inherit it.
➢ Use ContentPlaceHolder controls to specify a region that can be customized.
➢ MasterPage should contain at least one ContentPlaceHolder.
➢ Runtime user can change the MasterPage.
➢ The declaration for a MasterPage:
<%@Master Language="VB" CodeFile="SimpleCMS.master.cs" Inherits="SimpleCMS" %>
This tells the underlying ASP.NET framework how to handle this special page.
ContentPlaceHolder:
➢ Content placeholders are used to allocate places on the MasterPage that will be changed on the content pages.
➢ Content placeholder is a control in MasterPage. The content from the content page appears in the area made by
content placeholder control.
➢ There are two ContentPlaceHolder on any MasterPage.
1) In the Head section
2) In the between <form> </form>
➢ In the head user can specify certain Meta fields such as the page description and keywords. These vary from
page to page so if you're using a Master Page then this is where you would put one Place Holder.
➢ In the form section the actual webpage contents will paste.
➢ User can have multiple ContentPlaceHolders on the same page.
Content Pages:
➢ The content pages contain the content which user wants to display.
➢ For example, Home.aspx, Aboutus.aspx, Contactus.aspx, CheckMail.aspx, ContentPages, etc. are Content pages.
➢ User can define the content for the master page's placeholder controls by creating individual content pages,
which are ASP.NET pages that are bound to specific master page.
➢ When users request the content pages, they merge with the MasterPage to produce output that combines the
layout of the MasterPage with content from the content page.
Theme:
➢ Themes are an extension of another idea, like Master Pages. But Themes are different than Master Pages.
➢ A Master Page enables user to share content across multiple pages in a website.
➢ While Theme enables user to control the appearance of the content.
➢ A theme is a collection of property settings that allows user to define the look of pages and controls, and then
apply the look consistently across pages in a Web application, across an entire Web application, or across all
Web applications on a server.
➢ The concept is like, while one user may be visiting your site and seeing it one way, another user can be viewing
the exact same site, but get a completely different experience.
➢ Themes can be thought of as a container where user can store their own style sheets, images, skin files, etc.
➢ To apply theme to the web application, add new folder App_Theme by right clicking on Web Project.
➢ Themes are applied on the server. So we can change it runtime.
➢ A Theme folder can contain a variety of different types of files:
1) Skins
2) Cascading style sheets (CSS)
3) Images and other resources.
➢ Themes are control-based, not HTML-based. One of the advantages of Themes is that unlike CSS (only HTML
Controls) it allows user to define and reuse almost any control property.
➢ Themes can be applied through configuration file. In case if you want to have the luxury to apply a single theme
on the whole website you can do that too. You just have to apply it through configuration files for this purpose.
➢ Only one theme can be applied to each page.
Skin File:
➢ A skin generally contains visual properties (for look and feel strategies) of ASP.NET controls (server controls).
➢ The extension of skin file is .skin.
➢ It contains property settings for individual controls such as Button, Label, Textbox, Calendar etc. server side
controls.
➢ User can define skins in a separate file for each control or define all the skins for a theme in a single file.
➢ There are two types of skin files.
1) Default Skin
2) Named Skin
1) Default Skin :
➢ Default skin automatically applies to all controls of the same type when a theme is applied to a page.
➢ The SkinId is not defined.
➢ Only one default control skin per control type is allowed in the same theme.
2) Named Skin:
➢ It is a control skin with a SkinID property set.
➢ Named skins do not automatically apply to controls by type.
➢ In named skin, user can decide when you want to apply the skin.
➢ The Skinld should be uniquely defined because duplicate Skinld's per control type are not allowed in the same
theme.
CSS File:
➢ A Cascading Style Sheet (CSS) may be added to a Theme by placing it under the named Theme subdirectory.
➢ When user puts a .css file in the theme directory, the style sheet is applied automatically as a part of the theme.
➢ The CSS stylesheet will be applied to all pages with that theme applied.
➢ The Extension of the CSS file is .css.