Tuesday, January 13, 2015

Working with ASP.NET label and literal control

Today we show tutorial on how to work with ASP.NET's Label and Literal controls.



Label and Literal controls of ASP.NET are used to display text on web page.


  • Literal Control:

The literal control can only be used to display text that doesn't require any special formatting. Literal control does not support any of formatting that Label supports. This is just for very simple use.

Literal Properties:

  • Mode: Mode Property has 3 Values. These values have an effect on how text is displayed. 
    • Transform: If you add HTML tags in text field, it will transform text based on HTML tag.
    • PassThrough:It will pass all the tags and formatting through. 
    • Encode: This will ignore all HTML tags, and display them as text and not format text as per HTML tags.


Label Control:

Label control allows text to be formatted.  Label control renders its control in span tag. Hence, you can use Label tag as HTML tag, so you can place the content inside its tag rather then use text property.

You can use property window to change some properties of controls such as BackColor, ToolTip, BorderColor, Fonts, etc..

Label Properties: ID, Text



Please like, subscribe and share.

Working with Listbox control of ASP.NET

Today we see how to work with ASP.NET's Listbox Control in following video tutorial.




Listbox is collection of ListItem type of objects.

Items can be added to Listbox in HTML source or in some case ListBox can be bound to a database table or an XML file.

Several useful properties of ListBox control:
1.Rows
2.SelectionMode : Single or Multiple selection
 3. Selected: True or False
 4. DataTextField - Used when bounded with data
 5. DataValueField - Used when bounded with data

Please share, subscribe and like.

Working with ASP.NET Menu Controls

Today I share with you video tutorial on how to work with Menu Control of ASP.NET



Menu control of ASP.NET is collection of objects of type MenuItem.

It is navigation control that lets you create infinite number of levels with Menu->Sub Menu --> Sub Sub Menu and so on..

It has many formatting options. You can choose from built in styles or make your own style by setting various styles properties available with menu control.

In this video we are first going to create a menu design time and then at run time.

By run time I mean we will populate menu control at run time. Menu control will be present on form at design time but it will not have any object of type MenuItems. However since it will not be populated initially we will only see menu control once it becomes populated.

Selecting auto-format option give you list of pre-defined styles to format your menu.

You can add items in menu manually or automatically by selecting "Edit" items Editor" .

You can also bind your menu control with a data source (Usuallly an XML file) or sitemap or database table.

You can do this by selecting Choose Data Source --> New Data Source.

YOu can add item in menu by design time by clicking "Edit Menu Items" option from menu or select "Items" property from property window.

It will get you "Menu Item Editor" dialogue box. Using this window you can add items to menu and set various properties for menu items, individually.

Navigation URL property specifies a navigation path that is followed if particular menu item is selected

Procedure to add new items to menu is similar to adding new items to Listbox or DropdownList controls.

Here instead of making objects of type ListItems we make object of type MenuItems.

And then we can add object to Menu using Add() method.

Like we are setting Text property of MenuItem, you can set NavigationUrl property in same way.

Now, we want to add child to our menu.

We want to check if user has selected any item from menu or not, if user has selected any item from menu, new item that is added to menu is added as child of selected items otherwise, it is added as root.

For this we will write if condition to check if what item user has selected


Please share, subscribe and like.

Working with radio button control in ASP.NET

Today I share with you a video tutorial on how to work with radio button control in ASP.NET


Please watch, share and subscribe.
IndiBlogger - The Indian Blogger Community