Please visit our sponsors !
            
            ASP.NET - Server Controls
             
             
             
            Server controls are tags that can be understood by the server. 
             
            ASP Classic
            The listing below was copied from the previous chapter. 
            The inline code in red (also called a render block) is executed by the server 
before the page is sent to a browser: 
            
              
                  <html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
<p><%Response.Write(now())%></p>
</center>
</body>
</html>  |  
             
            Click on this link dynpage.asp to 
display the HTML page. 
            The code above illustrates a limitation in Classic ASP: The render block has 
to be placed where you want the output to appear.  
            With Classic ASP it is impossible to separate executable code from the HTML 
itself. This makes the page difficult to read, and difficult to maintain. 
             
            ASP.NET - Server Controls
            ASP.NET has solved the "spaghetti code" problem described above with 
something called server 
controls. 
            Server controls are tags that can be understood by the server. 
            There are three kinds of server controls: 
            
              - HTML Server Controls - Traditional HTML tags
 
              - Web Server Controls - New ASP.NET tags 
 
              - Validation Server Controls - allow you to validate input 
 
             
             
            ASP.NET - HTML Server Controls
             HTML server controls are standard HTML tags, 
except for one thing: they contain a runat="server" attribute. 
            This code illustrates how ASP.NET makes it possible to separate the 
executable code from 
the rest of the HTML: 
            
              
                  <%
TimeStamp.InnerText=now()
%>
<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
<p id="TimeStamp" runat="server"></p>
</center>
</body>
</html>  |  
             
            The runat="server" attribute in the example above, has turned the <p> tag 
into a server control. In addition the id attribute gives it a name to make it possible to reference 
it from executable code. 
            The executable code itself has been moved outside the HTML. 
             
            ASP.NET - Web Server Controls
            Web server controls are similar to HTML server controls, but more complex. They don't 
"act" as a part of an existing HTML tag but have a more "independent" existence. 
Web controls are often used in interactive applications such as input forms. 
            Web server controls are tags starting with <asp: 
            This code illustrates the use of Web server controls: 
            
              
                  <%
TimeStamp.Text=now()
%>
<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
<p><asp:label id="TimeStamp" runat="server" /></p>
</center>
</body>
</html>  |  
             
            Notice the Web server control called asp:label in the listing above. This is one of 
many predefined Web server controls that can be understood by ASP.NET. 
            Also notice the use of Text instead of InnerText to change the content of the 
tag. This is defined by the object model for this particular Web server control.  
             
            ASP.NET - Validation Server Controls
            Validation server controls allow you to validate an input server control 
(like a TextBox), and display a message when validation fails. 
            Each validation control performs a specific type of validation (like 
validating against a specific value or a range of values). 
            By default, page validation is performed when a Button, ImageButton, or 
LinkButton control is clicked. You can prevent validation when a button control 
is clicked by setting the CausesValidation property to false. 
             
             
             
            
Jump to: Top of Page
or HOME or
             
            Printer friendly page
             
             
            Search W3Schools:
            
             
            What Others Say About Us
            Does the world know about us? Check out these places: 
            
            Dogpile
            Alta Vista
            MSN
            Google
            Excite
            Lycos
            Yahoo
            Ask Jeeves
             
             
            We Help You For Free. You Can Help Us!
            
             
            
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
            terms of use and 
            privacy policy. 
            
            Copyright 1999-2002 by Refsnes Data. All Rights Reserved 
             
            
           |