My first ASP.NET page
My first ASP.NET page
Creating ASP.NET pages is easy. The basic syntax is much like HTML, so even if you don't know how to program,
you can still do quite a bit. A page in ASP.NET uses the extension .aspx, to distinguish them
from "Classic" ASP. Such a page is much like a form or dialog box in a Windows application. The page acts as an object
with controls, such as buttons and text boxes, that can fire events. These events can be handled on the server to provide
the user with a response. This is much like "Classic" ASP, but the programming model is closer to that of Visual Basic, Delphi,
and other languages that work an object based (visual) approach.
You can place controls on a page such as buttons, text boxes, list boxes, and much more. You can also create your
own controls. All controls generate pure HTML, so you don't have to worry about problems with older browsers,
and browsers that don't support Java or ActiveX controls.
At the heart of the page is the <form> tag known from HTML.
Added to this is the following attribute (with value) runat="server",
as follows:
<form runat="server">
</form>
As you can see this code looks much like HTML. Note that there are no additional attributes for the
<form> tag. ASP.NET generates these as needed. You can see that the result is pure
HTML when you view the resulting page in the browser. This HTML can be quite complex, but the nice thing is that you
don't have to worry about that. The following code shows how easy it is to create a fully functional page.
01calendar.aspx
<HTML>
<BODY>
<form runat="server">
<asp:calendar id="myCalendar" runat="server" />
</form>
</BODY>
</HTML>
The result of the code above is a nice looking calendar. You can click on the calendar to select a date. You can get the
selected date when the user is done. You can further layout the calendar using HTML like syntax, as follows:
02calendar.aspx
<HTML>
<BODY>
<form runat="server">
<asp:Calendar id="Calendar1" runat="server" BackColor="White" BorderColor="#999999" Width="350px" Height="350px" Font-Size="12pt" Font-Names="Verdana" DayNameFormat="FirstLetter" CellPadding="4">
<TodayDayStyle ForeColor="Black" BackColor="#CCCCCC" />
<SelectorStyle BackColor="#CCCCCC" />
<DayHeaderStyle Font-Bold="True" BackColor="#CCCCCC" />
<SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666" />
<TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999" />
<WeekendDayStyle BackColor="#AAAAFF" />
<OtherMonthDayStyle ForeColor="#808080" />
</asp:Calendar>
</form>
</BODY>
</HTML>
|