Basic controls in ASP.Net Assignment Help

Assignment Help: >> ASP.Net Programming >> Basic controls in ASP.Net

Basic controls in ASP.Net:

Button Controls:

ASP .Net gives three kinds of button controls: buttons, image buttons and link buttons. As the names suggest a button shows text within a rectangular area, a link button shows text that looks like a hyperlink. And an Image Button shows an image.

When a user presses a button control, two events are occurred Click and Command.

Basic syntax for button controls:

<asp:Button ID="Button1" runat="server"

            onclick="Button1_Click" Text="Click" />

Common attributes of the Button control:

Property

Description

Text

The text shown by the button. This is for link button and button controls only.

ImageUrl

For image button control only. The image to be shown for the button.

AlternateText

For image button control only. The text to be shown if the browser can't display the image.

CausesValidation

Calculates whether page validation occurs when a user clicks the button. The default is true.

CommandName

A string value that's passed to the Command type when a user clicks the button.

CommandArgument

A string value that's passed to the Command event when a user pressed the button.

PostBackUrl

The URL of the page that could be requested when the user pressed the button.

Text Boxes and Labels:

Text box controls are typically needed to accept input from the client. A text box control may take one or more lines to text relaying upon the setting of the TextMode attribute.

Label controls give a simple way to show text which may be modified from one execution of a page to the next. If you want to show a text that does not modified, you use the literal text.

Simple syntax for text controls:

<asp:TextBox ID="txtstate" runat="server" ></asp:TextBox

Common attributes of the Text Box and Labels:

Property

Description

TextMode

Denotes the type of text box. SingleLine prepares a standard text box, MultiLIne makes a text box that accepts more than one line of text and the Password causes the characters that are given to be masked. The default is SingleLine.

Text

The text type of the text box

MaxLength

The maximum number of characters that may be added into the text box.

Wrap

It calculates whether or not text wraps automatically for multi-line text box; default is true.

ReadOnly

Calculates whether the user may modifies the text in the box; default is false, i.e., the user may change the text.

Columns

The width of the text in characters. The actual width is calculated based on the font that's used for the text entry

Rows

The height of a multi-line text box in lines. The default value is 0, seems a single line text box.

The mostly needed attribute for a label control is 'Text', which shows the text shown the label.

Check Boxes and Radio Buttons:

A check box shows a single option that the user may either uncheck or check and radio buttons shows a group of options from which the user may choose just one option.

To make a group of radio buttons, you define the same name for the GroupName attribute of each radio button in the type. If more than one group is needed in a single form defines a different set name for every group.

If you want a check box or radio button to be marked when it's initially shown, set its marked attribute to true. If the Checked attribute is true for more than one radio button in a set, then only the last one may be selected.

Basic syntax for check box:

<asp:CheckBox ID= "chkoption" runat= "Server">

</asp:CheckBox>

Basic syntax for radio button:

<asp:RadioButton ID= "rdboption" runat= "Server">

</asp: RadioButton>

Common attributes of the Radio Buttons and Check Boxes:

Property

Description

Text

The text shown next to the check box or radio button.

Checked

Denotes whether it is chosen or not, default is false.

GroupName

Name of the set the control relates to.

List Controls:

ASP.Net gives the controls: drop-down list, radio button list, list box, bulleted list and check box list. These control let a user select from one or more related from the list.

List boxes and drop-down list has one or more list items. These lists should be loaded either by code or by the ListItem Collection Editor.

Basic syntax for list box control:

<asp:ListBox ID="ListBox1"

      runat="server"

      AutoPostBack="True"

      OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">

</asp:ListBox>

Basic syntax for a drop-down list control:

<asp:DropDownList ID="DropDownList1"

     runat="server"

     AutoPostBack="True"

     OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

</asp:DropDownList>

Common attributes of List box and Drop-down Lists:

Property

Description

Items

The set of ListItem objects that shows the items in the control. This property gives an object of type ListItemCollection.

Rows

Denotes the number of items displayed in the box. If actual list has more rows than displayed then a scroll bar is added.

SelectedIndex

The index of the currently marked item. If more than one item is marked, then the index of the first chosen item. If no item is marked, the value of this property is -1.

SelectedValue

The value of the currently marked item. If more than one item is marked, then the value of the first marked item. If no item is marked, the value of this property is an empty string("").

SelectionMode

Shows whether a list box allows multiple selections or single selections.

Common Properties of every list item objects:

Property

Description

Text

The text shown for the item

Selected

Shown whether the item is marked.

Value

A string value related with the item.

It is very important to shows that:

  • To work with the items in a list box or drop-down list, you need the Items property of the control. This property gives a ListItemCollection object which has all the items of the list.
  • The SelectedIndexChanged event is increased when the user marked a different item from a drop-down list or list box.

The List Item Collections:

The ListItemCollection object is a set of ListItem objects. Each ListItem object shown one item in the list. Items in a ListItemCollection are numbered from 0.

When the items into a list box are used strings like: lstcolor.Items.Add("Blue") . then both the Value and Text properties of the list item are define to the string value you specify. To mark it differently you must prepare a list item object and then include that item to the collection.

The ListItem Collection Editor is needed to include item to a drop-down list or list box. This is used to prepare a static list of items. To show the Collection Editor marks Edit item from the smart tag menu, or choose the control and then press the ellipsis button from the Item property in the Properties window.

Common Properties of List Item Collection:

Property

Description

Item(integer)

A ListItem object that shows the item at the specified index.

Count

The number of items in the set.

Common methods of List Item Collection:

Methods

Description

Add(string)

Includes a new item to the end of the collection and assigns the string parameter to the Text property of the item.

Add(ListItem)

Includes a new item to the end of the collection.

Insert(integer, string)

Inserts an item at the related index location in the collection, and gives the string parameter to the Text property of the item.

Insert(integer, ListItem)

Inserts the item at the related index location in the collection.

Remove(string)

Eliminates the item with the Text value same as the string.

Remove(ListItem)

Eliminates the specified item.

RemoveAt(integer)

Eliminates the item at the specified index as the integer.

Clear

Eliminates all the items of the collection.

FindByValue(string)

Gives the item whose Value is same as the string.

FindByValue(Text)

Gives the item whose Text is same as the string.

Radio Button list and Check Box list

A radio button list shows a list of mutually exclusive options. A check box list shows a list of independent options. These controls have a collection of ListItem objects that should be referred to through the Items property of the control.

Basic syntax for radio button list:

<asp:RadioButtonList ID="RadioButtonList1"

   runat="server"

   AutoPostBack="True"

   OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">

</asp:RadioButtonList>

Basic syntax for check box list:

<asp:CheckBoxList ID="CheckBoxList1"

   runat="server"

   AutoPostBack="True"

   OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">

</asp:CheckBoxList>

Basic Properties of Check Box and Radio Button Lists:

Property

Description

RepeatLayout

This attribute denotes whether the table tags or the normal html flow to use while formatting the list when it is shown. The default is Table

RepeatDirection

It denotes the direction in which the controls to be repeated. The values available are Vertical and Horizontal. Default is Vertical

RepeatColumns

It denotes the number of columns to use when repeating the controls; default is 0.

Bulleted lists and Numbered lists:

The bulleted list control makes bulleted lists or numbered lists. These controls have a collection of ListItem objects that should be referred to through the Items property of the control.

Basic syntax of a bulleted list:

<asp:BulletedList ID="BulletedList1" runat="server">

</asp:BulletedList>

Basic Properties of the Bulleted List:

Property

Description

BulletStyle

This property denotes the style and looks of the bullets, or numbers.

RepeatDirection

It denotes the direction in which the controls to be repeated. The values available are Vertical and Horizontal. Default is Vertical

RepeatColumns

It denotes the number of columns to use when repeating the controls; default is 0.

HyperLink Control:

The HyperLink control is same as the HTML <a> element.

Basic syntax for a hyperlink control:

<asp:HyperLink ID="HyperLink1" runat="server">

   HyperLink

</asp:HyperLink>

It has the given important properties:

Property

Description

ImageUrl

Path of the image to be shown by the control

NavigateUrl

Target link URL

Text

The text to be shown as the link

Target

The frame or window which will load the linked page.

Image Control:

The image control is used for showing images on the web page, or some alternative text, if the image is not given.

Basic syntax for an image control:

<asp:Image ID="Image1" runat="server">

It has the given important properties:

Property

Description

AlternateText

Alternate text to be shown

ImageAlign

Alignment options for the control button

ImageUrl

Path of the image to be shown by the control

 

Email based ASP.Net assignment help - homework help at Expertsmind

Are you searching ASP.Net expert for help with Basic controls in ASP.Net questions?  Basic controls in ASP.Net topic is not easier to learn without external help?  We at www.expertsmind.com offer finest service of ASP.Net assignment help and ASP.Net homework help. Live tutors are available for 24x7 hours helping students in their Basic controls in ASP.Net related problems. Computer science programming assignments help making life easy for students. We provide step by step Basic controls in ASP.Net question's answers with 100% plagiarism free content. We prepare quality content and notes for Basic controls in ASP.Net topic under ASP.Net theory and study material. These are avail for subscribed users and they can get advantages anytime.

Why Expertsmind for assignment help

  1. Higher degree holder and experienced experts network
  2. Punctuality and responsibility of work
  3. Quality solution with 100% plagiarism free answers
  4. Time on Delivery
  5. Privacy of information and details
  6. Excellence in solving ASP.Net queries in excels and word format.
  7. Best tutoring assistance 24x7 hours

 

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd