Introduction to asp+ syntax (3)----Preliminary server-side programming of asp+
Author:Eve Cole
Update Time:2009-05-30 19:54:14
This chapter introduces the server-side controls of Asp+. In addition to using the <%%> sign, asp+ program developers can now use new tags to generate dynamic pages. The new server controls can use a special tag in the asp+ file. tag runat=server to declare that the following server controls are used in the following example: <form runat=server>, <asp:textbox runat=server>, <asp:dropdownlist
runat=server>, and <asp:button runat=server> will automatically generate HTML code during operation.
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body>
<center>
<form action="intro4.aspx" method="post" runat=server>
<h3> Name: <asp:textbox id="Name" runat="server"/>
Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>
<asp:button text="Lookup" runat="server"/>
</form>
</center>
</body>
</html>
The result of this example is
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro4.aspx
Note: These server controls will generate HTML code on the client side, but the content of these server controls is not saved in Hidden, but is actually saved between pages, and there is no script code on the client side.
In addition to these input server controls, Asp+ allows developers to enrich some custom controls themselves, such as what we will see in the following example
The <asp:adrotator> control dynamically generates advertising images.
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body>
<center>
<form action="intro5.aspx" method="post" runat="server">
<asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/>
<h3> Name: <asp:textbox id="Name" runat="server"/>
Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>
<asp:button text="Lookup" runat="server"/>
</form>
</center>
</body>
</html>
The content of the advertising file is:
<Advertisements>
<Ad>
<ImageUrl>/quickstart/aspplus/images/banner1.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>
<Ad>
<ImageUrl>/quickstart/aspplus/images/banner2.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>
<Ad>
<ImageUrl>/quickstart/aspplus/images/banner3.gif</ImageUrl>
<TargetUrl>http://www.microsoft.com</TargetUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>
</Advertisements>
This example runs on:
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro5.aspx
The above is our brief description of the server controls for asp+ files. In the following lecture, we will explain some advanced asp+ server controls. Please support us as always!