Skip to main content

Posts

Showing posts with the label ASP.NET

How to add top margin to a Label in asp.net

Add top margin to a Label control The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can add the top margin to a Label web server control. To add the top margin to a Label control, the asp.net c# developers have to apply a custom CSS style to a Label control. In the below example code, we demonstrate two ways to add the top margin to a Label web server control. The Label CssClass property gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. The CssClass property is inherited from WebControl. The CssClass property value is a String which is the CSS class rendered by the Label server control on the client. The defaul...

How to add margin to a Label in asp.net

Add margin to a Label The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can add a margin to a Label web server control. To add a margin to a Label control, the asp.net c# developers have to apply a custom CSS style to a Label control. The Label CssClass property gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. The CssClass property is inherited from WebControl. The CssClass property value is a String which is the CSS class rendered by the Label server control on the client. The default value of this property is Empty. So finally, using this CssClass property the asp.net c# developers can add a margin to ...

How to justify the text in a Label in asp.net

Justify text in a Label control The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can justify the text on a Label web server control. To justify text in a Label control, the asp.net c# developers have to apply a custom CSS style to a Label control. The Label CssClass property gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. The CssClass property is inherited from WebControl. The CssClass property value is a String which is the CSS class rendered by the Label server control on the client. The default value of this property is Empty. So using this CssClass property the asp.net c# developers can justify tex...

How to trim text with ellipsis in a Label in asp.net

Trim text with ellipsis on a Label The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can trim a text with an ellipsis and display it on a Label web server control. To show an ellipsis on a Label control, the asp.net c# developers have to apply a custom CSS style to a Label control. The Label CssClass property gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. The CssClass property is inherited from WebControl. The CssClass property value is a String which is the CSS class rendered by the Label server control on the client. The default value of this property is Empty. So finally, using this CssClass propert...

How to display html tags in a Label in asp.net

Show HTML tags on a Label The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can display HTML tags in a Label web server control. To show HTML tags on a Label control, the asp.net c# developers have to encode HTML tags. The Server HTMLEncode() method applies HTML encoding to a specified string. The HTMLEncode() method is very useful and a quick method of encoding form data and other client request data before using it in a Web application. Encoding data converts potentially unsafe characters to their HTML-encoded equivalent. The Server HTMLEncode() method has a parameter named string which specifies the string to encode. The Server HTMLEncode() method ha...

How to add an onClick event to a Label in asp.net

Add an onClick event to a Label The Label class Represents a label control, which displays text on a Web page. The asp.net developers can use the Label control to display text in a set location on the web page. Unlike static text, asp.net c# developers can customize the displayed text through the Text property. The following asp.net c# tutorial code demonstrates how we can add an onClick event to a Label web server control. But there is no built-in onClick event in the Label control. So we have to find an alternate solution to attach a click event to a Label control. In the below asp.net c# code, we used the Label control’s Attributes property to add a click event to a Label web server control. The Attributes property allows us to add a javascript click event to a Label server control. The Label Attributes property gets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control. This p...

asp.net - Deselect Calendar selected date on second click

Deselect Calendar selected date on second click Calendar is an asp.net rich web server control that provide us a way to select an individual dateor date range. this example code demonstrate us an interesting technique to deselect calendar selected date on second click. first click on any date cell we can select a date from calendar control and we can change the selection of calendar date by selectinganother date or date range from calendar control. calendar server control has no built in feature to deselect selected date on second clickand it has no feature to select random date from calendar control. to select random date from calendar control and deselect selected date on second click we need to apply few techniques.to do this we created an event handler for calendar SelectionChanged event. we stored the calendar selected dates in a bulletedlist items collection.when users click a date in calendar control then we test it that the buletedl...

asp.net - How to add custom text to a day cell in a Calendar

Add custom text in Calendar Individual Day Cell Calendar is an ASP.NET web server control. Users can select an individual date or date range in a Calendar control. Calendar OnDayRender() method raises the DayRender event of calendar control that allows us to write a custom handler for the DayRender event. The Calendar DayRender event occurs when each day is created in the control hierarchy for the Calendar control. We can add static control to a calendar’s specific date cell before Calendar display in a web browser such as Literal, Image, and Hyperlink control. ASP.NET Literal server control reserves a location on the web page to display static text. So if we can add a Literal control on the Calendar individual date cell then we can add any static text to any date cell in the Calendar control. First, we need to create a Literal control programmatically in the DayRender event handler section. Then we add static text to Literal control which we...

asp.net - How to apply css style on Calendar individual day cell

Apply CSS style in Calendar individual Day Cell Calendar is an ASP.NET web server control. This web server control allows us to select an individual date or date range at a time. Calendar control is rendered as an HTML table and each day of Calendar control contains a LinkButton control that raises an event when it is clicked. Calendar control has many built-in properties to set or change its day cell's text color, background color, border style, etc. But Calendar control has no property to change its individual day cell or any specific day cell styles programmatically. The Calendar DayRender event occurs when each day is created in the control hierarchy of the Calendar control. So it is possible to change the style of any individual day cell in Calendar control before it displays in the web browser. By using this event we can modify the appearance of a specific day cell or multiple cells before it displays on the web page. The Cale...

asp.net - How to use Calendar DayRender event

Calendar DayRender event The Calendar is an ASP.NET web server control that allows us to select an individual date or date range. The Calendar displays the dates for one month at a time with a total of six weeks appearing at the same time. In an ASP.NET web page Calendar server control is rendered as an HTML table. By default, each day of Calendar control contains a LinkButton control that raises an event when it is clicked. The Calendar DayRender event occurs when each day is created in the control hierarchy of the Calendar control. DayRender event is raised when each date cell in the Calendar control is created. So it is possible to modify the date cell content and format the individual date cells before it is displayed on the web page. We can write an event handler for the Calendar DayRender event to customize the content and appearance of any specific date cell or cells. We can add only static control to any date cell such as Literal, Labe...

asp.net - How to use Calendar SelectionChanged event

How to use Calendar SelectionChanged event in asp.net Calendar is an asp.net rich web server control. calendar control displays the dates for one month at a time. total six weeksappearing at the same time. users can select an individual date from calendar control. even users can select multiple dates (date range)from a calendar server control. calendar SelectionChanged event occurs when the users select an individual date or range of dates. by using this event we can determinewhat date or dates the user has selected. we can write an event handler for calendar SelectionChanged event to display user selecteddate or dates in web page after postback. to get the calendar selected dates we loop through the calendar SelectedDates collection using for loop and display the selected date liston web page. the following asp.net c# example code demonstrate us how can we use the calendar SelectionChanged event in an asp.net application. Calenda...

How to use ListView control in asp.net

ListView Web Server Control ListView is an ASP.NET web server control. ListView allows us to data bind with DataSource and display data. We can show ListView data items on pages. ListView can display data items individually or it can group data items. .NET developers can format data using templates and styles in a ListView control. ListView is popular for displaying data in any repeating structure. It is a similar server control to the DataList and Repeater server control. But ListView has more facilities such as the user can edit, update, insert, delete, sort, and even page data. All those are ListView built-in features, so you don't need to code for any one facility. LisView can data bind with SqlDataSource control using its DataSourceID property. By binding data with data source control we can get its built-in advantage such as paging data, sorting data, inserting, deleting, and editing data. ListView DataSource property allows us...

asp.net - How to change Panel horizontal align programmatically

Change Panel horizontal alignment programmatically The Panel represents a control that acts as a container for other controls. The Panel is especially useful when the asp.net developers want to generate controls programmatically, hide and show a group of controls, or localize a group of controls. The Panel’s Direction property is used to display text in the Arabic language. The following asp.net c# tutorial code demonstrates how we can change the horizontal alignment of a Panel web server control. Here we change the Panel’s horizontal alignment to center and right programmatically. In the below code example, we used the Panel control’s HorizontalAlign property to change its horizontal alignment programmatically. The Label HorizontalAlign property gets or sets the horizontal alignment of the contents within the panel. The HorizontalAlign property value is one of the HorizontalAlign values. The default value of this property is NotSet. Th...

asp.net - How to show and hide a Panel programmatically

Show (visible) and hide Panel programmatically The Panel is an asp.net web server control that acts as a container control for other asp.net controls and HTML elements. Panel inside controls act as a group of controls. So we can apply common properties of the Panel's inside controls by setting the panel's properties such as showing or hiding all controls, aligning and directing controls, etc. Panel Visible property accepts a Boolean value. if we set the Panel Visible property value to false then it hides all inside controls from the web page with the Panel itself. Panel Visible property value True means the Panel and its inside controls will render in web pages and all elements are visible to visitors. We can control the Panel and its inside controls visibility using Panel's Visible property. The Visible property value True and False works as a switch to rendering or not rendering the Panel on the web page. The Panel acts as a par...

How to change menu static item hover style in asp.net c#

Static hover style in menu control The Menu is an ASP.NET web server control. Menu control's StaticHoverStyle property gets a reference to the style object that allows us to set the appearance of a static menu item when the mouse pointer is positioned over it. This property value type is System.Web.UI.WebControls.Style. This Style represents the style of a static menu item when the mouse pointer is positioned over it. The StaticHoverStyle property has a few sub-properties. we can set the property both declaratively and programmatically. The declarative syntax is Property-Subproperty and the programmatic syntax is Property.Subproperty (StaticHoverStyle.BackColor). So we can set the static menu item hover style as setting the background color, text color, border style, border width, font name, text size, etc. The following ASP.NET C# example code demonstrates to us how can we set or change the Menu control's static menu items hover style...

asp.net - Change TreeView root node style programmatically

Change TreeView root node style programmatically The TreeView is an asp.net web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure. The following asp.net c# tutorial code demonstrates how we can programmatically change the TreeView web server control’s root node style. The asp.net c# developers can set the TreeView root node style using its RootNodeStyle property. The TreeView RootNodeStyle property gets a reference to the TreeNodeStyle object that allows us to set the appearance of the root node in the TreeView control. The TreeView RootNodeStyle property value is TreeNodeStyle which is a reference to the TreeNodeStyle that represents the style of a node in the TreeView. The TreeNodeStyle class represents the style of a node in the TreeView control. The TreeView RootNodeStyle property controls the de...

asp.net - Change TreeView node style programmatically

Change TreeView node style programmatically The TreeView is an asp.net web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure. The following asp.net c# tutorial code demonstrates how we can programmatically change the TreeView web server control’s node style. The asp.net c# developers can set the TreeView node style using its NodeStyle property. The TreeView NodeStyle property gets a reference to the TreeNodeStyle object that allows us to set the default appearance of the nodes in the TreeView control. The TreeView NodeStyle property value is TreeNodeStyle which is a reference to the TreeNodeStyle that represents the default style of a node in TreeView. The TreeNodeStyle class represents the style of a node in the TreeView control. The TreeView NodeStyle property controls the default appearance of a nod...

asp.net - Change TreeView leaf node style programmatically

TreeView leaf node style programmatically The TreeView is an asp.net web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure. The following asp.net c# tutorial code demonstrates how we can programmatically change the TreeView web server control’s leaf node style. The asp.net c# developers can set the TreeView leaf node style using its LeafNodeStyle property. The TreeView LeafNodeStyle property gets a reference to the TreeNodeStyle object that allows you to set the appearance of leaf nodes. The TreeView LeafNodeStyle property value is TreeNodeStyle which is a reference to the TreeNodeStyle that represents the style of the leaf nodes in the TreeView. The TreeNodeStyle class represents the style of a node in the TreeView control. The TreeView control allows us to specify different style characteristics such...

asp.net - Programmatically show and hide CheckBox in a TreeView

Show and hide checkboxes in a TreeView programmatically The TreeView is an asp.net web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure. The following asp.net c# tutorial code demonstrates how we can show and hide checkboxes in a TreeView control programmatically. The asp.net c# developers can change the checkboxes visibility of a TreeView programmatically using its ShowCheckBoxes property. The TreeView ShowCheckBoxes property gets or sets a value indicating which node types will display a check box in the TreeView control. The ShowCheckBoxes property value is a TreeNodeTypes. The TreeNodeTypes represent the different node types (leaf, parent, and root) in the TreeView control. The TreeView ShowCheckBoxes property value is a bitwise combination of the TreeNodeTypes values. The default is TreeNodeType....

asp.net - Change TreeView image set programmatically

Change TreeView image set programmatically The TreeView is an asp.net web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure. The following asp.net c# tutorial code demonstrates how we can programmatically change the TreeView image set. The asp.net c# developers can change the image set of a TreeView programmatically using its ImageSet property. The TreeView ImageSet property gets or sets the group of images to use for the TreeView control. The ImageSet property value is one of the TreeViewImageSet values. The default is TreeViewImageSet.Custom. In this asp.net tutorial, we set the TreeView ImageSet property value to TreeViewImageSet.Faq and TreeViewImageSet.Msdn on button click event. The TreeViewImageSet.Faq is a predefined set of FAQ-styled images. And the TreeViewImageSet.Msdn is a predefined set ...