| ASP.Net Web Server Control |
| |
| ASP.NET 2.0 Standard Web Server Controls |
| |
| The standard Web server controls can be divided into following categories: |
| |
⢠Basic Web Server Controls
⢠Basic Controls
⢠Selecting Values Controls
⢠Selecting List Values Controls
⢠Table Controls
⢠Container Control
⢠Image Controls
⢠Advance Web Controls |
| |
| The Basic web server controls are listed below: |
| |
| Basic Controls |
| |
| Label Web Server Control |
| |
| This control allows you to present static text on the page and operate it programmatically. The Label control is alike to the Literal control, except Label allows you to apply style properties to the text. |
| |
| Syntax: |
| |
| <asp:Label id="MyLabel" Text="Mylabel" runat="server"/> |
| |
| Literal Web Server Control |
| |
| The Literal control is used to display static text on the Web Forms page. Unlike the Label control, Literal does not allow you to apply styles to its content. |
| |
| Ensure that Text is not HTML encoded before it is displayed in the Literal control. This makes it possible to embed script within HTML tags in the text. Make sure to validate the values to help prevent security vulnerabilities, if the values for the control coming from user input. |
| |
Syntax:
<asp:Literal
EnableTheming="True|False"
EnableViewState="True|False"
ID="string"
Mode="Transform|PassThrough|Encode"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
runat="server"
SkinID="string"
Text="string"
Visible="True|False"/> |
| |
| Button Web Server Control |
| |
| The Button control let you to create a push button on the Web Forms page. There are two types of buttons that can be created. You can create either a submit button or a command button. |
| |
| A Button control is a submit button by default. A submit button does not have a command name associated with the button and simply posts the Web page back to the server. You can provide an event handler for the Click event to programmatically control the actions performed when the submit button is clicked. |
| |
| Syntax: |
| |
| The following example show the declaration for a submit button control in an .aspx file. |
| |
| <asp:Button id="MySubmitButton" Text="Submit" OnClick="MySubmitBtn_Click" runat="server"/> |
| |
| The following example demonstrates the declaration for a command button control in an .aspx file. |
| |
| <asp:Button id="MySortButton" Text="MyAscending" CommandName="MySort" CommandArgument="Ascending" OnCommand="MyCommandBtn_Click" runat="server"/> |
| |
| You can use the command code in the event handler, the event handler is available in aspx.cs or aspx.vb page by selecting the required button and press double click. Alternatively, you can also write this code within the script tag of the aspx page. |
| |
| LinkButton Web Server Control |
| |
| The LinkButton control is used to create a hyperlink-style button on a Web Forms page. Specify the text to display in the LinkButton control by either setting the Text property or placing the text between the opening and closing tags of the LinkButton control. You can create either a submit button or a command button. |
| |
| Here important to Note that the LinkButton control has the same appearance as a HyperLink control, but has the same functionality as a Button control. |
| |
| A submit button does not have a command name associated with the button and simply posts the Web page back to the server. By default, a LinkButton control is a submit button. |
| |
| Syntax: |
| |
<asp:LinkButton id="MyLinkButton" Text="Mylabel" Command="Command"
CommandArgument="CommandArgument" CausesValidation="true | false"
OnClick="OnClickMethod" runat="server"/> |
| |
| Or |
| |
<asp:LinkButton id="LinkButton1" Command="Command" CommandArgument="CommandArgument" CausesValidation="true | false" OnClick="OnClickMethod" runat="server"/> Text
</asp:LinkButton> |
| |
| HyperLink Web Server Control |
| |
| A HyperLink control is used to create a link that moves to another page or different location on the same page. You can set the page or location to link to by using the NavigateUrl property. The link can either be displayed as text or an image. To display text, either set the Text property or simply place the text between the opening and closing tags of the HyperLink control. Specify the ImageUrl property to display an image. |
| |
| Syntax: |
| |
| <asp:HyperLink id="MyHyperLink" NavigateUrl="url" Text="HyperLinkText" ImageUrl="url" Target="window" runat="server"/> |
| |
| or |
| |
<asp:HyperLink id=" MyHyperLink """ NavigateUrl="url" ImageUrl="url" Target="window" runat="server"> Text |
| |
| TextBox Web Server Control |
| |
| The TextBox server control is an input control. By default, the TextMode property is set to SingleLine, which creates a text box with only one line. There two other available options are MultiLine or Password. MultiLine used to create a text box with more than one line. Password used to create a single-line text box that masks the value entered by the user. |
| |
| Syntax: |
| |
<asp:TextBox id="value" AutoPostBack="True|False" Columns="characters" MaxLength="characters" Rows="rows" Text="text"
TextMode="SingleLine | MultiLine | Password" Wrap="True|False" OnTextChanged="OnTextChangedMethod" runat="server"/> |
| |
| Selecting Values Web controls |
| |
| CheckBox Web Server Control |
| |
| The CheckBox control creates a check box on the Web Forms page that allows the user to switch between a true or false state. You can specify the caption to display in the control by setting the Text property. The caption can appear either on the right or left of the check box. Set the TextAlign property to specify the side that the caption appears on. The CheckBox control<asp:CheckBox> element has no content, you can use close the tag with /> instead of using a separate closing tag. To find out whether the CheckBox control is checked, use the checked property. |
| |
| Syntax: |
| |
<asp:CheckBox id="CheckBox1" AutoPostBack="True|False" Text="Label" TextAlign="Right|Left" Checked="True|False" OnCheckedChanged="OnCheckedChangedMethod" runat="server"/> |
| |
| RadioButton Web Server Control |
| |
| RadioButton Web Server Control creates a single radio button on the page. The grouping of multiple radio buttons together present a mutually exclusive set of choices. The grouping of multiple radio buttons is done by specifying the same GroupName for each RadioButton control. Set the text to display in the control by setting Text property RadioButton control. The text can appear either on the left or the right of the radio button. |
| |
| Syantax: |
| |
<asp:RadioButton id="RadioButton1" AutoPostBack="True|False" Checked="True|False" GroupName="GroupName" Text="label" TextAlign="Right|Left" OnCheckedChanged="OnCheckedChangedMethod" runat="server"/> |
| |
| Selecting List Values Web controls |
| |
| DropDownList Web Server Control |
| |
| This control shows a drop-down list that agrees to the user to select a single item from the list. The DropDownList control offers a single selection drop-down list control. You can modify the appearance of the DropDownList control by setting the BorderColor, BorderStyle, and BorderWidth properties. |
| |
| You can set the items that appear in the DropDownList control, place a ListItem element for each entry between the opening and closing tags of the DropDownList control. |
| |
| The DropDownList control also supports data binding. The DropDownList control will now display the information from the data source. The SelectedIndex property can be used to programmatically find out the index of the item selected from the DropDownList control. |
| |
| Syntax: |
| |
<asp:DropDownList id="MyDropDownList1" runat="server"
DataSource="<% databinding %>"
DataTextField="MyDataSourceField"
DataValueField="MyDataSourceField"
AutoPostBack="True|False"
OnSelectedIndexChanged="OnSelectedIndexChangedMethod">
<asp:ListItem value="valueofitem" selected="True|False">
Text
</asp:ListItem>
</asp:DropDownList> |
| |
| CheckBoxList Web Server Control |
| |
| CheckBoxList Web Server Control used to create a multiselection check box group that can be dynamically created by binding the control to a data source. To specify items that you want to show in the CheckBoxList control, place a ListItem element for each entry between the opening and closing tags of the CheckBoxList control. The CheckBoxList control also supports data binding. To find out the selected items in the CheckBoxList control, use the Items collection and check the Selected property of each item in the collection. |
| |
| Syntax: |
| |
<asp:CheckBoxList id="MyCheckBoxList"
AutoPostBack="True|False"
CellPadding="InPixels"
DataSource='<% databinding %>'
DataTextField="DataSourceFieldName"
DataValueField="DataSourceFieldName"
RepeatColumns="ColumnCountNo"
RepeatDirection="Vertical|Horizontal"
RepeatLayout="Flow|Table"
TextAlign="Right|Left"
OnSelectedIndexChanged="OnSelectedIndexChangedMethod"
runat="server">
<asp:ListItem value="valueoflistitem" selected="True|False">
Text
</asp:ListItem>
</asp:CheckBoxList>
|
| |
| ListBox Web Server Control |
| |
| The ListBox control is used to create a list control that permits single or multiple item selection. You can use the Rows property to set the height of the control. To facilitate multiple item selection, set the SelectionMode property to ListSelectionMode.Multiple. |
| |
| Put a ListItem element for each entry between the opening and closing tags of the ListBox control to specify the items that you want to appear in the ListBox control. It also supports data binding. Use the DataTextField and DataValueField properties to specify which field in the data source to bind to the Text and Value properties, respectively, of each list item in the control. The ListBox control will now display the information from the data source. |
| |
| If the SelectionMode property is set to ListSelectionMode.Multiple, then you can find out the selected items in the ListBox control by iterating through the Items collection and testing the Selected property of each item in the collection. For setting the SelectionMode property use the ListSelectionMode.Single, now you can use the SelectedIndex property to determine the index of the selected item. The index can then be used to retrieve the item from the Items collection. |
| |
| Syntax: |
| |
<asp:ListBox id="MyListbox=" DataSource="<% databinding %>"
DataTextField="DataSourceFieldName" DataValueField="DataSourceFieldName"
AutoPostBack="True|False" Rows="rowcountno" SelectionMode="Single|Multiple" OnSelectedIndexChanged="OnSelectedIndexChangedMethod" runat="server">
<asp:ListItem value="value" selected="True|False"> |
| |
Text
</asp:ListItem>
</asp:ListBox> |
| |
| RadioButtonList Web Server Control |
| |
| The RadioButtonList control allows you to create a single-selection radio button group that can be dynamically generated by binding to a data source. To specify the items that you want to appear in the RadioButtonList control, place a ListItem element for each entry between the opening and closing tags of the RadioButtonList control. |
| |
| It is important to Note that you can also use the RadioButton control, but RadioButtonList control is easier for creating a set of radio buttons using data binding. An individual RadioButton control gives you greater control over layout than RadioButtonList control. |
| |
| The RadioButtonList control also supports data binding. The DataTextField and DataValueField properties can be used to specify which field in the data source to bind to the Text and Value properties, respectively, of each list item in the control. The RadioButtonList control will now display the information from the data source. |
| |
| You can find out the selected items in the RadioButtonList control, loop through the Items collection and test the Selected property of each item in the collection. |
| |
| You can set the rendering of the list with the RepeatLayout and RepeatDirection properties. If RepeatLayout is set to RepeatLayout.Table (the default setting), the list will be rendered within a table. If it is set to RepeatLayout.Flow, the list will be rendered without any tabular structure. The RepeatDirection is set by default to RepeatDirection.Vertical. Set this property to RepeatDirection.Horizontal to render the list horizontally. |
| |
| Syntax: |
| |
| <asp:RadioButtonList id="MyRadioButtonList" AutoPostBack="True|False" CellPadding="InPixels" DataSource="<% databinding %>" DataTextField="DataSourceFieldName" DataValueField="DataSourceFieldName" RepeatColumns="ColumnCountNo" RepeatDirection="Vertical|Horizontal" RepeatLayout="Flow|Table" TextAlign="Right|Left" OnSelectedIndexChanged="OnSelectedIndexChangedMethod" runat="server"> <asp:ListItem Text="label" Value="value" Selected="True|False" /> </asp:RadioButtonList> |
| |
| BulletedList Web Server Control |
| |
| The BulletedList Web Server control generates an unordered or ordered (numbered) list of items, which provide as an HTML ul or ol element, respectively. You can specify the appearance of the items and of the bullets or numbers, define the list items statically or by binding the control to data, and you can respond to users' clicks on items. |
| |
| The BulletedList originate from the same ListControl class as the ListBox, DropDownList, and other ASP.NET list controls, so using it is similar to working with those controls. |
| |
| To define items for the BulletedList control, two properties are needed to define two properties: the Text property and the Value property. The Text property describes what the control displays on the page. The Value property describes a second value that is not displayed but that you might want to return when a user selects an item. |
| |
| Syntax: |
| |
<asp:BulletedList id="MyBulletedListt" AutoPostBack="True|False"
CellPadding="InPixels"
RepeatDirection="Vertical|Horizontal" RepeatLayout="Flow|Table" TextAlign="Right|Left" OnSelectedIndexChanged="OnSelectedIndexChangedMethod" runat="server"> <asp:ListItem Text="label" Value="value" Selected="True|False" />
</asp: BulletedList > |
| |
| Tables Web controls |
| |
| Table Web Server Control |
| |
| You can construct table at design time with static content, but the Table web server control can also be constructed programmatically with dynamic contents. The Table class allows you to construct an HTML table and specify its characteristics. |
| |
| It important to note, the programmatic additions or modifications to a table row or cell will not persist across posts to the server. Table rows and cells are controls of their own, not properties of the Table control. Changes to table rows or cells must be reconstructed after each post to the server. If substantial modifications are expected, use the DataList or DataGrid controls instead of the Table control. |
| |
| Each Table control is made up of rows (represented by instances of the TableRow class) stored in the Rows collection of the control. Each row is made up of cells (represented by instances of the TableCell class) stored in the Cells collection of the each TableRow. |
| |
| You can display an image in the background of the Table control by setting the BackImageUrl property. By default, the horizontal alignment of the items in the table is not set. To specify the horizontal alignment, set the HorizontalAlignment property. The spacing between individual cells is restricted by the CellSpacing property. To specify the amount of space between the contents of a cell and the cell's border, set the CellPadding property. To display the cell borders, set the GridLines property. You can put on view the horizontal lines, vertical lines, or both horizontal and vertical lines. |
| |
| Syntax: |
| |
<asp:Table id="MyTable" BackImageUrl="url" CellSpacing="cellspacing" CellPadding="cellpadding" GridLines="None|Horizontal|Vertical|Both" HorizontalAlign="Center|Justify|Left|NotSet|Right" runat="server">
<asp:TableRow> <asp:TableCell> Cell text </asp:TableCell>
</asp:TableRow>
</asp:Table> |
| |
| TableRow Web Server Control |
| |
| TableRow Web Server Control represents a row in the Table control and allows controlling it programmatically. |
| |
| The rows of a table are stored in the Rows collection of the Table control. An instance of the TableRow class signifies a row in a Table control. This class allows you to control how the contents of the row are displayed. By setting the HorizontalAlign and VerticalAlign properties, you can control how the contents of the row are displayed in the row. |
| |
| Syntax: |
| |
| <asp:TableRow id="TableRow1" HorizontalAlign="Center|Justify|Left|NotSet|Right" VerticalAlign="Bottom|Middle|NotSet|Top" runat="server"> <asp:TableCell> Cell text </asp:TableCell> </asp:TableRow> |
| |
| TableCell Web Server Control |
| |
| TableCell Web server control represents a cell in a Table control and allows you to operate it programmatically. The cells of each row are stored in the Cells collection of the TableRow representing the row. An instance of the TableCell class signifies a cell in a Table control. You can control the contents of a cell by using the Text property. |
| |
| Setting the HorizontalAlign and VerticalAlign properties specifies the horizontal and vertical alignment of the contents in the cell, respectively. You can use the Wrap property to specify whether the contents of the cell automatically continue on the next line when the end of the cell is reached. |
| |
| The RowSpan and ColumnSpan properties control that how many rows or columns a cell occupies in the Table control respectively. |
| |
| Syntax: |
| |
<asp:TableCell id="MyTableCell"
ColumnSpan="noofcolcount"
RowSpan="noofrowcount"
HorizontalAlign="Center|Justify|Left|NotSet|Right" VerticalAlign="Bottom|Middle|NotSet|Top"
Wrap="True|False" runat="server">
Cell text
</asp:TableCell> |
| |
| Container Web Control |
| |
| Panel Web Server Control |
| |
| Panel Web Server Control offers a container for other controls. This control is rendered as an HTML <div> element. |
| |
| The Panel control is act as a container for other controls. It is particularly useful for producing controls programmatically and displaying and hiding groups of controls. You can display an image in the background of the Panel control by setting the BackImageUrl property. Using the HorizontalAlignment property, you can specify the horizontal alignment of the items contained in the control. You can set the Wrap property that automatically continues the contents on the next line when a line is longer than the width of the panel. |
| |
<asp:Panel id="Panel1"
BackImageUrl="url"
HorizontalAlign="Center|Justify|Left|NotSet|Right"
Wrap="True|False"
runat="server">
(Other controls declared here)
</asp:Panel> |
| |
| PlaceHolder Web Server Control |
| |
| The PlaceHolder control is used as a container to store dynamically added server controls to the Web page. The PlaceHolder control does not generate any visible output and is only used as a container for other controls on the Web page. |
| |
| You can use the Control.Controls collection to add, insert, or remove a control from the PlaceHolder control. |
| |
| Syntax: |
| |
Syntax:
<asp:PlaceHolder EnableTheming="True|False"
EnableViewState="True|False" ID="anystring"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
runat="server"
SkinID="string"
Visible="True|False" /> |
| |
| Image Control |
| |
| Image Web Server Control |
| |
| Image Web Server Control presents a Web-compatible image. The Image control is used to display an image on the Web Forms page. You can specify the path to the displayed image by setting the ImageUrl property. You can specify the text to display in place of the image when the image is not available by setting the AlternateText property. The ImageAlign property specifies the alignment of the image in relation to other elements on the Web Forms page. |
| |
| It is important to note that this control only displays an image. To behave like a button or need to find out the coordinates where the mouse pointer is clicked on the image, use the ImageButton control such requirements. As the <asp:Image> element has no content, you can close the tag with /> instead of using a separate closing tag. |
| |
Syntax:
<asp:Image id="MyImage" runat="server"
ImageUrl="imgaeurlstring"
AlternateText="Imagealtstring"
ImageAlign="NotSet|AbsBottom|AbsMiddle|BaseLine|
Bottom|Left|Middle|Right|TextTop|Top"/> |
| |
| ImageButton Web Server Control |
| |
| ImageButton control displays an image and permits you to handle user click events on the server. Set the image to display in the control by setting the ImageUrl property. |
| |
| Both the Click and Command events are raised when the ImageButton control is clicked. |
| |
| You can use the OnClick event handler to programmatically to find out the coordinates where the image is clicked. You can then code a response based on the values of the coordinates. |
| |
| You can use the OnCommand event handler to make the ImageButton control behave like a command button. This allows multiple ImageButton controls to be placed on the same Web page. The value of the CommandName property can then be programmatically identified in the OnCommand event handler to determine the appropriate action to perform when each ImageButton control is clicked. The CommandArgument property can also be used to pass additional information about the command, such as specifying ascending order. As <asp:ImageButton> element has no content, you can close the tag with /> instead of using a separate closing tag. |
| |
| By default, page validation is executed when an ImageButton control is clicked. Page validation verifies whether the input controls associated with a validation control on the page pass the validation rules specified by the validation control. If you have an ImageButton control that needs to disable this behavior, such as a reset button, set the CausesValidation property to false. |
| |
Syntax:
<asp:ImageButton id="MyImageButton"
ImageUrl="Iamgeurlstring"
Command="UsingCommand"
CommandArgument="CommandArgument"
CausesValidation="true | false"
OnClick="OnClickMethod"
runat="server"/> |
| |
| Advanced Web Server Controls |
| |
| AdRotator Web Server Control |
| |
| The AdRotator control displays an advertisement banner on a Web Forms page. It displays the image specified by the ImageUrl element within an anchor control. In Asp.Net, the AdRotator control uses a separate XML advertisement file to store the advertisement information, such as the location of the image to display and the URL of the page to link to. The AdvertisementFile property of the AdRotator control specifies the path to this file. |
| |
| To create the advertisement file, opening and closing
tags mark the beginning and the end of the file, respectively. Opening and closing tags delimit each advertisement. All advertisements are nested between the opening and closing tags. If the file contains multiple tags, only the first set of tags in the file will be parsed by the AdRotator control. All other tags will be ignored. |
| |
| The data elements for each advertisement are nested between the opening and closing <Ad> tags. Although certain data elements are predefined (such as ImageUrl and NavigateUrl), you can place custom elements between the
<Ad> tags. These elements will be read by the AdRotator control when it parses the file. The information is then passed to the AdCreated event in the AdProperties dictionary property. |
| |
| The data elements that are predefined for the XML advertisement file are given following: |
| |
1 <ImageUrl>: The complete or relative URL to an image file (optional).
2. <NavigateUrl>: The URL of a page to link to if the user clicks the ad (optional).
Note: If this element is not set, the HRef property is not rendered on the anchor tag.
3. <AlternateText>: The text display in place of the image when the image specified by the ImageUrl property is not available (optional).
4. <Keyword>: A category for the advertisement (for example, "computers") that you can filter by (optional).
5. <Impressions>: A number that indicates the importance of the ad in the schedule of rotation relative to the other ads in the file (optional). |
| |
| The larger the number, the more often the ad is displayed. The total of all Impressions values in the XML file cannot exceed 2,047,999,999. If it does, the AdRotator throws a run-time exception. |
| |
| The following shows the format for the XML advertisement file. |
| |
<Advertisements>
<Ad>
<ImageUrl> URL of image to display for Advertisement #1 </ImageUrl>
<NavigateUrl> URL of page to link to for Advertisement #1 </NavigateUrl>
<AlternateText> Text to show as a ToolTip for Advertisement #1 </AlternateText>
<Keyword> Keyword used to filter for Advertisement #1 </Keyword>
<Impressions> Relative importance of Advertisement #1 </Impressions> <CustomInformation>
Custom Data about Advertisement #1 </CustomInformation>
</Ad>
</Advertisements> |
| |
| At run time, the AdRotator control uses <asp:HyperLink> and <asp:Image> controls to render the control on the Web Forms page. The source image is sized by the browser to the dimensions of the AdRotator control, regardless of its actual size. |
| |
| If the AdvertisementFile property is set, an advertisement is selected based on the value of the Impressions property from the file. The event arguments are then set and the AdCreated event is raised. If the AdvertisementFile property is not set, the event arguments are empty when the AdCreated event is raised. The event arguments are used to render the AdRotator control, so you can modify the values passed to the event from the advertisement file, or set them with values you generate yourself. A common scenario is to populate the event arguments with values retrieved from a database. |
| |
| When you create an advertisement file, consider the following points: |
| |
⢠The XML in the advertisement file must be well formed.
⢠Only the first <Advertisements> element in the file is parsed by the AdRotator control. All other <Advertisements> elements within the file are ignored.
⢠You can add custom elements to the XML description of an advertisement. These values are passed to the AdCreated event in the AdProperties dictionary property. |
| |
| You can use the AdCreated event to select the advertisements directly in your code or to modify the rendering of an ad selected from the advertisement file. If an advertisement file is set, the arguments to the AdCreated event are already set to the selected ad when the event is called. Whether or not the values are already set, you can modify the values in the ImageUrl, NavigateUrl, and AlternateText properties to modify the rendering of the AdRotator control. Custom elements added to the XML description of the advertisement are available in the AdCreatedEventArgs.AdProperties dictionary property. |
| |
Syntax:
<asp:AdRotator id="Value"
AdvertisementFile="AdvertisementFile"
KeyWordFilter="KeyWord" Target="Target"
OnAdCreated="OnAdCreatedMethod" runat="server"/> |
| |
| Calendar Web Server Control |
| |
| The Calendar control presents a one-month calendar that allows the user to select dates and move to the next and previous months. |
| |
| You can disable date selection entirely or enable by setting the SelectionMode property. You can specify whether the user can select a single day, a week, or a month. |
| |
| You can customize the look of the Calendar control by setting the style properties for the different parts of the control. The list of the style properties for the Calendar control is following: |
| |
| Style Property |
Explanation |
| DayHeaderStyle |
This property used to set the style for the section of the calendar where the names of the days of the week appear. |
| DayStyle |
This property used to set the style for the individual days in the displayed month. You can set Weekends, the current date, and the selected day by setting the WeekendDayStyle and SelectedDayStyle properties, respectively. |
| NextPrevStyle |
This property set the style for the sections at the left and right ends of the title bar where the month navigation LinkButtoncontrols are located. |
| OtherMonthDayStyle |
This property set the style for the days from the previous and next month that appear on the current month view. |
| SelectedDayStyle |
This property used to set the style for the selected date.
Note: If this property is not set, the style specified by the DayStyleproperty is used to display the selected date. |
| SelectorStyle |
This property set the style for the column on the left of the Calendarcontrol containing links for selecting a week or the entire month. |
| TitleStyle |
This property set the style for the title bar at the top of the calendar containing the month name and month navigation links.
Note:If NextPrevStyleis set, it overrides the style for the next and previous month navigation controls located at the ends of the title bar. |
| TodayDayStyle |
This property set the style for the current date.
Note:If this property is not set, the style specified by the DayStyleproperty is used to display the current date. |
| WeekendDayStyle |
This property set the style for the weekend days.
If this property is not set, the style specified by the DayStyleproperty is used to display the weekend dates. |
|
| |
Calendar control uses TableItemStyle class as style class for all above style properties.
You can also control the appearance of the Calendar control by displaying or hiding different parts of the control. The following lists the parts of the Calendar control that can be displayed or hidden. |
| |
| Property |
Explanation |
| ShowDayHeader |
To displays or hides the section that displays the days of the week. |
| ShowGridLines |
To displays or hides the grid lines between the days of the month. |
| ShowNextPrevMonth |
To displays or hides the navigation controls to the next or previous month. |
| ShowTitle |
Displays or hides the title section. |
|
| |
| Calendar control doesnât support binding to a data source, but you can modify the content and formatting of the individual date cells. |
| |
| It is important to note that the client browser must have JavaScript enabled for Calendar control to function properly. |
| |
Syntax:
<asp:Calendar id="MyCalendar"
CellPadding="Inpixels"
CellSpacing="Inpixels"
DayNameFormat="FirstLetter|FirstTwoLetters|Full|Short"
FirstDayOfWeek="Default|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday"
NextMonthText="HTML text"
NextPrevFormat="ShortMonth|FullMonth|CustomText"
PrevMonthText="HTML text"
SelectedDate="date"
SelectionMode="None|Day|DayWeek|DayWeekMonth"
SelectMonthText="HTML text"
SelectWeekText="HTML text"
ShowDayHeader="True|False"
ShowGridLines="True|False"
ShowNextPrevMonth="True|False"
ShowTitle="True|False"
TitleFormat="Month|MonthYear"
TodaysDate="date"
VisibleDate="date"
OnDayRender="OnDayRenderMethod"
OnSelectionChanged="OnSelectionChangedMethod"
OnVisibleMonthChanged="OnVisibleMonthChangedMethod" runat="server">
<TodayDayStyle property="value"/>
<DayHeaderStyle property="value"/>
<DayStyle property="value"/>
<NextPrevStyle property="value"/>
<OtherMonthDayStyle property="value"/>
<SelectedDayStyle property="value"/>
<SelectorStyle property="value"/>
<TitleStyle property="value"/>
<TodayDayStyle property="value"/>
<WeekendDayStyle property="value"/>
</asp:Calendar> |
| |
| Xml Web Server Control |
| |
| The Xml control is used to show the contents of an XML document or the results of an XSL Transform. |
| |
| The display of an XML document, specify the setting one of three properties. These are properties are following: |
| |
1 Document: Sets the XML document using a System.Xml.XmlDocument object.
2 DocumentContent: Sets the XML document using a string.
3 DocumentSource: Sets the XML document using a file. |
| |
| You can display a System.Xml.XmlDocument, an XML string, or an XML file by setting the appropriate property. |
| |
| It is important to note that to display an XML document, you must set at least one of the XML document property. If more than one XML document property is set, the XML document in the last property set is displayed. The documents in the other properties are ignored. |
| |
| This property is commonly set declaratively by placing text between the opening and closing <asp:Xml> tags of the Xml control. |
| |
| The two properties represent the different types of XSL Transform documents that can be used to format the XML document. You can format the XML document with a System.Xml.Xsl.XslTransform or with an XSL Transform file by setting the appropriate property. The two properties are given following: |
| |
1 Transform: Formats the XML document using the specified
System.Xml.Xsl.XslTransform.
2 TransformSource: Formats the XML document using the specified XSL Transform file. |
| |
Syantax:
<asp:Xml id="MyXmlDoc"
Document="MyXmlDocument object to display"
DocumentContent="XMLString"
DocumentSource="XML
DocumentPath" Transform="XslTransform obj"
TransformSource="XSL Transform Document Path" runat="server"> |
| |
| It is important to note that the XSL Transform document is optional. There is no need to set the Transform or the TransformSource properties. The last set property determines which XSL Transform document is used to format the XML document, if both XSL Transform document properties are set. The other property is ignored. |
| |
| Web server controls offer all of the features described above for HTML server controls (except one-to-one mapping to elements) and these additional features: |
| |
⢠A rich object model that presents type-safe programming capabilities.
⢠The controls can identify browser capabilities and render appropriate markup.
⢠For some controls, the ability to define your own layout for the control using Templates.
⢠For some controls, the ability to specify whether a control's event causes immediate posting to the server or is instead cached and raised when the page is submitted.
⢠Maintain a common look using themes, which enable you to define a consistent look for controls throughout your site.
⢠Web Server controls can pass events from a nested control (such as a button in a table) to the container control. |
| |
| Categorization of the server controls provided by ASP.NET |
| |
1. Fundamental Controls
These are the HTML based controls like Textbox, Text Area, etc.
2. Data-Centric Controls
These controls are specially designed for the database connectivity and provide the binding facility, e.g. List controls.
3. Rich Controls
Controls like the Calendar and Data Grid are examples of rich controls.
4. Validation Controls
These controls are provided for usage with the intrinsic controls and provide functionality of data validation. |
| |
|
| |