Web Studyaspnet.blogspot.com Babyneed.blogspot.com

ASP.Net Web Developer Guide

Power By: eXTReMe Tracker Powered by Blogger  
 
 
 
 

 

 
Important Links
 
   
     
 
Sitemap
 
   
   
 
Reference
 
   

Thursday, March 09, 2006

A Simple Application Using ASP Server Controls(Chapter 3)

In this example, we will develop the same application using ASP.NET Server Controls. At this stage, we have two choices.We may either use HTML Server controls or Web Server controls. Just for the sake of experimentations, we will use the <asp:listbox> Web Server Control, and the <input type=“button”> HTML Server Control. Irrespective of which type of controls we use, we will need to add a new attribute in the tags for these controls.When we create an instance of these controls, we will specify its runat attribute to be “server” such as <asp:listbox id=“lstFlowers” runat=“server/>. The output is shown in Figure 3.7. Its revised code is shown in Figure 3.8 and can be found on the CD that accompanies this book.
Once a flower is selected and the command button is clicked, the client will receive a new instance of the form from the server, however, the selected value of the list box will persist.This phenomenon is known as state-full.This is because the ASP.NET controls maintain their states in spite of the state-less nature of the HTTP protocol.

Figure 3.7 The Flower Selection Application Using ASP.NET Server Controls


Figure 3.8 The Code for ServerControl1.aspx (ServerControl1.aspx)
<!— Chapter3\ServerControl1.aspx —>
<html><head></head><body>
<form runat="server" action ="ServerControl1.aspx">
Select a flower, and then click the submit button please. You
will see that the page remembers your selection.<br/><br/>
<asp:ListBox runat="server" rows="3">
<asp:ListItem>Tulip</asp:ListItem>
<asp:ListItem>Poppy</asp:ListItem>
<asp:ListItem>Iris</asp:ListItem>
</asp:ListBox><br/><br/>
<input type="submit" value="Submit" runat="server"/>
</body></form></html>

0 Comments:

Post a Comment

<< Home