0
<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 <%# Css4Item(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.

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.