I'm using a repeater control and want to add some processing in it so that when the page equals the link the class on that link is set to selected (see below)
The problem is I want to get the value that is held in
<%# Eval("url") %> on each 'loop' and use it within the code. I thought
<%
s = Eval("url")
%>
would work, but obviously I'm misunderstanding the system. Is there anyway to get the value held in Eval("url") outside a <%# %> statement, or is this just not possible.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1">
<HeaderTemplate>
<clear />
<div id="Menu">
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><a href="<%# Eval("url") %>" alt="<%# Eval("description") %>"
<%
Dim pagestr As String
Dim s As String
s = Eval("url")
pagestr = Mid(Request.ServerVariables("URL"), InStrRev(Request.ServerVariables("URL"), "/") + 1)
If StrComp(pagestr, s) = 0 Then
Response.Write(" class=""selected""")
End If%>><%# Eval("title") %></a></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</asp:Repeater>
I'm trying to create a side menu in which the current page's link is in bold and all the others plain. I can't use the ASP2 menu conrol as unfortunately I'm building some pages within someone elses site and theyv'e made modifications to this control which mean I can't control the style.
The problem is I want to get the value that is held in
<%# Eval("url") %> on each 'loop' and use it within the code. I thought
<%
s = Eval("url")
%>
would work, but obviously I'm misunderstanding the system. Is there anyway to get the value held in Eval("url") outside a <%# %> statement, or is this just not possible.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1">
<HeaderTemplate>
<clear />
<div id="Menu">
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><a href="<%# Eval("url") %>" alt="<%# Eval("description") %>"
<%
Dim pagestr As String
Dim s As String
s = Eval("url")
pagestr = Mid(Request.ServerVariables("URL"), InStrRev(Request.ServerVariables("URL"), "/") + 1)
If StrComp(pagestr, s) = 0 Then
Response.Write(" class=""selected""")
End If%>><%# Eval("title") %></a></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</asp:Repeater>
I'm trying to create a side menu in which the current page's link is in bold and all the others plain. I can't use the ASP2 menu conrol as unfortunately I'm building some pages within someone elses site and theyv'e made modifications to this control which mean I can't control the style.