HyperLink click problem
<li>
<asp:HyperLink ID="hlLogin" runat="server"
CssClass='<%# Css4Item(Eval("Page.Request.Path")) %>'
Text="Prijava" NavigateUrl="~/Login.aspx"></asp:HyperLink>
</li>
protected string Css4Item(object url)
{
return url.ToString().EndsWith(Page.Request.Path,
StringComparison.OrdinalIgnoreCase) ? "active" : string.Empty;
}
How can i execute <%# Cs开发者_StackOverflows4Item(Eval("Page.Request.Path")) %>
that i will get path to my Css4Item method when i click on hyperLink. This code is not executed. when i click on link nothing happens.
This code will execute only into a bindable container, 'cause you're using the Data-Binding expression syntax.
For some reason if you try to use the ResponseWrite into an attribute of webcontrols (something in the form '<%= %>') doesn't work, I think you've to set the CssClass from code behind, in the page lifecycle (probably on Page_Load).
精彩评论