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
FAQ
Login
 
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 > Microsoft's ASP.Net
 
Next

ASP.NET Tutorial - Microsoft's ASP.NET

 
                                                                                                               Page 3 of 6
 

Advantages of ASP.NET Controls

The concept of ASP.NET controls is elucidated to develop smart ASP.NET forms. A “smart” form was earlier developed (in example2) by converting the standard HTML form tags into server side HTML tags. So the question arises as to why use ASP.NET controls at all.

Benefits of using ASP.NET controls

  • ASP.NET controls represent the HTML elements of a page in an intuitive object model.
  • ASP.NET controls, automatically retain the value of their properties by participating in view state (view state will be explained in the next section).
  • ASP.NET controls enable you to separate the design content of a page from the application logic.
  • ASP.NET controls enable you to maintain browser compatibility while still supporting advanced browser features such as JavaScript.

Using ASP.NET Controls

 In the following section, using ASP.NET controls will enhance Example 2. Modify the page according to the Example 3 and save it with the name DisplayMessage.aspx in the same directory.

Example3:DisplayMessage.aspx

<Script Runat="Server">

Sub Submit (Obj as Object, e As EventArgs)

lblName. Text = "Your Name is: &nbsp; <b>" & txtName.text &"</b>"

lblComments. Text="Your Comments are: &nbsp; <b>"&txtComments.text &"</b>"

End Sub

</Script>

<html>

<head><title>AspNetControls.aspx</title></head>

<body>

<b>

Click on the button to view the messages:

</b>

<form Runat="Server">

<asp:textbox id="txtName" runat="server"/><p>

<asp:TextBox

ID="txtComments" textmode="multiline" columns="50" rows="10"

Runat="Server" /><p>

<asp:Button

id="btnSubmit"

Text="Send Comment!"

OnClick="Submit"

Runat="Server" />

<p>

<asp:Label id="lblName" Runat="Server" /><p>

<asp:Label id="lblComments" Runat="Server" />

</form>

</body>

</html>

 

The output of this example is shown below:

It is seen that when the form button is clicked, the subroutine named Submit is executed. This subroutine assigns the text “John” and “See the magic of ASP.NET controls” to the Label control with ID lblName and lblComments. It picks this text from the TextBox control with ID txtName and txtComments which is entered by the user.

The Submit subroutine is associated with the Button control through the control’s OnClick method. You can name the subroutine, as you want; there is nothing magical about the name Submit.

The Submit subroutine is declared within the <Script Runat=”Server”> tags at the top of the page. Note that the subroutine accepts two parameters of type Object and EventArgs. The significance of these parameters will is explained below:

Whenever you need to write code to respond to a click button, you use a similar subroutine. The first argument passed to the subroutine represents the object that triggers the event.

In Example 3 the button control with the ID btnSubmit triggers the event. Object parameters can be used to determine the particular object that triggers the subroutine and then responses can be made accordingly.

       

 

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