PDA

View Full Version : changing part of the asp code to asp.net


urko
05-21-2008, 06:42 PM
Hi
I use this code to select the tab colour in my asp page:

<ul>
<li <% if currentPage = "home" then response.write("id='current'") %>><a href="home.asp">Home</a></li>
</ul>


does any1 knows how it should be in asp.net??
just started to play with .net and dont really know much.

thanks

chump2877
05-23-2008, 01:48 AM
ASP.NET is event-driven, so you'd have something like:

.aspx file
<asp:BulletedList
BulletImageUrl="~/Images/bullet1.JPG"
BulletStyle="CustomImage"
DisplayMode="HyperLink"
ID="BulletedList1"
runat="server">
<asp:ListItem Value="http://www.contoso.com/">Contoso</asp:ListItem>
<asp:ListItem Value="http://www.asp.net/">ASP.NET</asp:ListItem>
</asp:BulletedList>

.cs code-behind file
protected void Page_Load(object sender, EventArgs e)
{
if (Request.ServerVariables("URL") == "home.aspx")
{
BulletedList1.CssClass = "current";
}
}

And the CSS:
.current li
{
// styles here
}