开发者

Problem with declarative statement at asp.net 2.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开发者_JS百科., 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜