Web Server Controls

February 4, 2011

1. Button Control-
<asp:Button id=”MyButton”     Text=”label”     CommandName=”command”     CommandArgument=”commandargument” CausesValidation=”true | false”     OnClick=”OnClickMethod”     runat=”server”/>

The Button control is used in creating the push buttons on the web page. There are two types of the buttons, Submit and Command buttons. Here the submit button simply posts back to the same page of aspx. Whereas the Command buttons are to help in creating different button controls to perform event handling with the script at the server page.

Here the ID is what used in referring to its properties in the scripting. Text refers to the label on the button to display. OnClick will refer to the method name that will get to the code behind function, in c# or Vb. By default the button click causes the validation for a page as per the given validation conditions for every field in the form. We can disable this by setting “CausesValidation” to false.

Command button uses the “CommandName” to differentiate all the command buttons from each other on the same page. “CommandArgument” shall stay as an additional information for the command button control.

2. CheckBox Control:

<asp:CheckBox id=”CheckBox1″      AutoPostBack=”True|False”     Text=”Label”     TextAlign=”Right|Left”     Checked=”True|False”     OnCheckedChanged=”OnCheckedChangedMethod”     runat=”server”/>

The checkbox control is used in the forms to add a checkbox control allowing the user to select or deselect. This to have a switch between true or false in the control.

Here the Text property to give the caption of the checkbox control. TexAlign property to set the alignment of the caption either to left or right. Checked property to set it by default as checked if set to true. The “onCheckedChanged” is the event handler used to call the method from the code behind.

CheckBoxList control is the one that is used along with multiple checkboxes to have a grouped set of them in a container of a CheckBoxList.

“AutoPostBack”, is to be enabled if we are interested in to have a post back to take place on a click over the checkbox. But by default it is disabled.

3. HyperLink Web Server Control:

<asp:HyperLink id=”HyperLink1″     NavigateUrl=”url”     Text=”HyperLinkText”     ImageUrl=”url”     Target=”window”     runat=”server”/>
<asp:HyperLink id=”HyperLink1″””     NavigateUrl=”url”     ImageUrl=”url”     Target=”window”     runat=”server”>   Text</asp:HyperLink>

The HyperLink control is used to create a link that on click moves to other page. Here the NavigateUrl property gives the value of the URL link where the page has to be redirected.Then the Text property is used for the need to display text for the active link or the ImageUrl property set to refer to the URL of the image which is used as the link control. If both Text and ImageUrl are given, then the ImageUrl takes a precedence above the text.

The Target propeerty refers to the value given to refer to the control, what kind of redirection it has to be. The  Target valuue can be -_blank:Display the link in a new window without frames. _parent:Display the page in the frameset parent, _self: Display the page in the same frameset itself. _top:Display the page in a full window without frames.

To be continued…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: