Library tutorials & articles
Using ASP.NET Server Controls
- Overview
- What's the big deal?
- Anatomy of ASP.NET Page
- Controls
- Summary
Anatomy of ASP.NET Page
I have constructed a very simple ASP.NET page to illustrate how very simple it is.
<% @Page language="C#"%>
<html>
<script language="C#" runat=server>
private void btnclick_click(object sender, EventArgs e)
{
if (cmbcolor.SelectedItem.Text == "red")
lblcolor.BackColor = System.Drawing.Color.Red;
if (cmbcolor.SelectedItem.Text == "blue")
lblcolor.BackColor = System.Drawing.Color.Blue;
if (cmbcolor.SelectedItem.Text == "yellow")
lblcolor.BackColor = System.Drawing.Color.Yellow;
if (cmbcolor.SelectedItem.Text == "green")
lblcolor.BackColor = System.Drawing.Color.Green;
}
</script>
<body>
<form action="intro.aspx" method="post" runat="server">
<asp:Label runat="server" id="lblcolor" Text="COLOR CHANGE DEMO"/>
<br><br>
<asp:DropDownList id=cmbcolor runat="server">
<asp:ListItem Value="red">red</asp:ListItem>
<asp:ListItem Value="blue">blue</asp:ListItem>
<asp:ListItem Value="yellow">yellow</asp:ListItem>
<asp:ListItem Value="green">green</asp:ListItem>
</asp:DropDownList>
<br><br>
<asp:Button Text="Click Here" id="btnClick"
onClick="btnclick_click" Runat=server />
<br>
</form>
</body>
</html>
|
One new piece of code is the new <%@PAGE %> directive. It controls a lot of functionality for your page. One of the most useful is the ASPCOMPAT attribute, - this Boolean value determines if the page is backward compatible. You must set this attribute to true if you are calling legacy ActiveX DLL's.
Related articles
Related discussion
-
Profile Class does not work after Translation
by converter2009 (1 replies)
-
what is the SQL Server Provider
by hayperaktib (1 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
-
Java Script, File uploading on ftp server using java script code
by h_c_a_andersen (2 replies)
-
sharepoint calendar web part with events from sql table
by converter2009 (2 replies)
Related podcasts
-
StackOverflow uses ASP.NET MVC - Jeff Atwood and his technical team
Scott chats with Jeff Atwood of CodingHorror.com and most recently, StackOverflow.com. Jeff and Joel Spolsky and their technical team have created a new class of application using ASP.NET MVC. What works, what doesn't, and how did it all go down?
Events coming up
-
Mar
15
DevWeek 2010
London, United Kingdom
DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.
It would have made article more intresting if it was told which controls to be used in different conditions.
This thread is for discussions of Using ASP.NET Server Controls.