So far I've resorted to using <ul> / <li>'s for menu items and putting
an <asp:hyperlink> in the list item, then in the code behind.. getting
the current URL and regex checking it against each menu option's URL
and adding a class="selected" to the relevant link.. (horrible
really).. It works, but it feels bad.. at least it keeps the markup
clean and the CSS works, no JS anywhere..


On Feb 17, 3:28 pm, Drew Crawford <[email protected]> wrote:
> I'm interested to see what kind of response there is to this.  I have the
> same issue (which I've been putting on the back burner lately).  Would be
> nice to hear of a good solution already out there, instead of coming up with
> one from scratch.
>
> On Mon, Feb 16, 2009 at 11:18 AM, peteski <[email protected]> wrote:
>
> > Hi all,
>
> > I might be off the mark here, but having spent all afternoon trying to
> > find a way to add a class to a <li> element to specify which menu item
> > represents the current page in a menu..
>
> > I've looked at using the asp:menu control; I have found it to be akin
> > to using Comic Sans on a site - surely in 2009 we should be able to
> > simply and quickly configure the way we want out menu output, complete
> > with Id's classes etc.. and without .net slapping its horrible id's on
> > the front of my own: ct100_header_myElement.
>
> > Using sitemap doesn't seem to give the flexibility either, I ended up
> > simply coding the <ul> myself, which I have no problem with, fair
> > enough it's not the answer to all solutions - but when you want to be
> > able to easily format your markup it sure seems better!
>
> > I'm using an image replacement technique on the <a> tags inside my
> > <li>'s, I've tried getting hold of the <li> in code behind on page
> > load to attach a "current" class to the relevant item with no joy
> > (I've tried runat="server" on EVERYTHING)!.
>
> > I've looked at what seems to be a crippled and more or less dead
> > project CSS Friendly Adaptors (now on Google groups).. and I'm close
> > to giving up - I remember in PHP you could simply use strstr($loc,
> > "what_Im_Looking_for"); granted not always the best solution, but
> > given the scale of my project just what I would want right now..
>
> > I want .net to be #1 .. my #1.. can anyone give me a lifeline here?
>
> > Thanks
> > Pete

Reply via email to