ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication

Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses


  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > Begining Web Forms

ASP.NET Tutorial - Begining Web Forms

                                                                                                                 Page 6 of 6

Example on Web Controls

Using Web controls is just like using HTML server controls. They are created on the server and events are handled by specifying properties and methods. Many of them post data to the server. The working of two of the most common Web controls the Label and Button controls have already been discussed.

Web Controls in action are shown below with the help of an example.

Example 11 webcontrols.aspx

<%@ Page Language="VB" %>

<script runat="server">

Sub Submit (obj as object, e as EventArgs)

Dim strIncome as string =country.SelectedItem.Text

Dim strAge as string=r1Age.SelectedItem.Text

lblmessage. Text = "Hi " & tbName. Text & "! <p>" & _

"Your Country is: " & strIncome & "<br>" & _

"Your age is: " & strage & "<br>"

If r1Age. SelectedIndex<3 then

lblmessage. Text + = "You’re a young one! <p>"


lblmessage. Text + = "You’re a wise one! <p>"

End if

If cbname. Checked then

lblmessage. Text + = "We will keep your name confidentially."

End if

End sub




<h2>Web server Control Example</h2><hr>

<form runat="server">


<asp:Label id="lblHeader" runat="server" />


<asp:Label id="lblmessage" runat="server" /> <p>

Enter Your Name:

<asp:TextBox id="tbname" runat="server" /> <p>

Choose your age: <br>

<asp:RadioButtonList id="r1age" runat="server" Repeat Direction="horizontal">

<asp:ListItem> <18</asp:ListItem>

<asp:ListItem> <19-24</asp:ListItem>

<asp:ListItem> <25-34</asp:ListItem>

<asp:ListItem> <35-49</asp:ListItem>

<asp:ListItem> <50-65</asp:ListItem>

</asp: RadioButtonList> <p>

Choose your Country: <br>

<asp:ListBox id="country" runat="server" size=2>


<asp:ListItem> CANADA</asp:ListItem>

<asp:ListItem> INDIA</asp:ListItem>

<asp:ListItem> AUSTRALIA</asp:ListItem>


</asp: ListBox> <p>


Do you want to keep your name confidential? <Br>

<asp:CheckBox id= "cbname" runat="server" text="Yes!" /> <p>

<asp:button id="btSubmit" Onclick="Submit" text="Submit" runat="server" />






In the above example we have used the following web controls:

  • Label,
  • TextBox,
  • RadioButtonList,
  • ListBox and
  • Button

The working of these controls are also seen in the above example. Each web control renders to an existing HTML element, and no controls are actually sent to the browser. Nothing new is found after viewing the source i.e. the entire HTML is perfectly satisfactory to the browser (You must do this by right clicking on the browser and then click on View Source)



Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
© ExpertRating 2015. All Rights Reserved.