0

wanna ask you for help. I am bit lost with declarative statement in asp.net 2.0.
I want add specific class "selected" or "noselected" for A tag when current path is equal to path I provide. I tried st., but it is not working. The code is below:
<a href="<%# DataBinder.Eval(Container.DataItem, "Url") %>" class="<%# (DataBinder.Eval(Container.DataItem, "Url").ToString().Equals(Request.RawUrl))?"selected":"notselected" %>">linkname</a>

the value of "Url" is "/SubDir/SecondPage.aspx"

I am not sure if short "IF" statment works and if I compare right values of urls. If you see guys something significant, would be great.

Thanks. X.

[EDIT] OK, the code above is completely fine, no need to change it. the problem was in me.Beat me.

Jaroslav Urban
  • 1,269
  • 3
  • 20
  • 32

1 Answers1

1

The concept looks fine. You might want to try ToLower() on both the URL string value and the RawUrl.

Rex M
  • 142,167
  • 33
  • 283
  • 313
  • Well it wasnt exactly solution, cause the statment works as you said. The problem was between keybord and screen.Anyway thanks – Jaroslav Urban Nov 02 '09 at 22:37