ASP.NET
  Home arrow ASP.NET arrow Page 5 - Completing a Web Form in ASP.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Completing a Web Form in ASP.NET
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 23
    2006-06-15

    Table of Contents:
  • Completing a Web Form in ASP.NET
  • How to use the required field validator
  • How to add code to a form
  • How to use page and control events
  • How to run a web site with the built-in development server

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Completing a Web Form in ASP.NET - How to run a web site with the built-in development server


    (Page 5 of 5 )

    When you run a file-system web site by using one of the techniques in figure 2-17, Visual Studio 2005 compiles the application. If the application compiles without errors, Visual Studio automatically launches the built-in ASP.NET 2.0 Development Server and displays the starting page of the web site in your default browser. Then, you can test the application to make sure that it works the way you want it to.

    However, if any errors are detected as part of the compilation, Visual Studio opens the Error List window and displays the errors. These can consist of errors that have to be corrected as well as warning messages. In this figure, all of the errors have been corrected, but 7 warning messages are displayed in the Error List window.

    To fix an error, you can double-click on it in the Error List window. This moves the cursor to the line of code that caused the error in the Code Editor. By moving from the Error List window to the Code Editor for all of the messages, you should be able to find the coding problems and fix them.

    As you’re testing an application with the development server, exceptions may occur. If an exception isn’t handled by the application, ASP.NET switches to the Code Editor window and highlights the statement that caused the exception. In this case, you can end the application by clicking on the Stop Debugging button in the Debug toolbar or using the Debug->Stop Debugging command. Then, you can fix the problem and test again.

    In chapter 4, you’ll learn all of the debugging skills that you’ll need for more complex applications. For simple applications, though, you should be able to get by with just the skills you have right now.

    An ASP.NET project with the shortcut menu for a web form displayed


    Figure 2-17.  How to run a web site with the built-in development server

    How to run an application

    • Click on the Start button in the Standard toolbar or press F5. Then, the project is compiled and the starting page is displayed in your default browser.
    • The first time you run an ASP.NET application, a dialog box will appear asking whether you want to modify the web.config file to enable debugging. Click the OK button to proceed.

      How to stop an application
    • Click the Close button in the upper right corner of the browser. Or, if an exception occurs, click the Stop Debugging button in the Debug toolbar or press Shift+F5. 

      How to fix build errors
       
    • If any errors are detected when the project is compiled, an Error List window is opened and a list of errors is displayed along with information about each error. To display the source code that caused an error, double-click on the error in the Error List window.
    • After you’ve fixed all of the errors, run the application again, and repeat this process if necessary. Note, however, that you don’t have to fix the warnings.

    How to review the HTML that’s sent to the browser

    To view the HTML for a page that’s displayed in a browser, you can use the Source command in your browser’s View menu. To illustrate, figure 2-18 presents the HTML that’s sent back to the browser after I selected a new value from the drop-down list, entered new values into the text boxes, and clicked the Calculate button. Although you’ll rarely need to view this code, it does give you a better idea of what’s going on behind the scenes.

    First, you’ll see that this code doesn’t include any asp tags. That’s because these tags are rendered to standard HTML so the controls they represent can be displayed in the browser. For instance, the asp tag for the drop-down list in the first row of the table has been converted to an HTML select tag.

    Second, you can see that the view state data is stored in a hidden input field named _ViewState. Here, the value of this field is encrypted so you can’t read it. Because the data in view state is passed to and from the browser automatically, you don’t have to handle the passing of this data in your code.

    Third, you can see that the data that I selected from the drop-down list is included in the HTML. Although you can’t see it, the data that was entered into the text boxes is included as well. This illustrates that you don’t need view state to save the information that’s entered by the user. Instead, view state is used to maintain the state of properties that have been set by code. For example, it’s used to maintain the values that are loaded into the drop-down list the first time the user requests the form.

    Keep in mind that this HTML is generated automatically by ASP.NET, so you don’t have to worry about it. You just develop the application by using Visual Studio in the way I’ve just described, and the rest of the work is done for you.

    The HTML for the Future Value form after a post back


    Figure 2-18.  How to review the HTML that's sent to the browser 

    Description

    • To view the HTML for a page, use the View->Source command in the browser’s menu.
    • The HTML that the browser receives consists entirely of standard HTML tags because all of the ASP.NET tags are converted to standard HTML when the page is rendered.
    • View state data is stored in a hidden input field within the HTML. This data is encrypted so you can’t read it.
    • If the page contains validation controls and client scripting is enabled for those controls, the HTML for the page contains script to perform the validation on the client if the client supports DHTML.
    • Values that the user enters into a page are returned to the browser as part of the HTML for the page.

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Murach's ASP.NET 2.0 Web Programming with...
     

    Buy this book now. This article is excerpted from the book Murach's ASP.NET 2.0 Web Programming with VB2005, written by Doug Lowe (Murach, 2006; ISBN: 1890774324). Check it out today at your favorite bookstore. Buy this book now.

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT