How and where do i assign "Selected" to menuitem of asp:menu controlon page load?

A

alexandis

I have menu bound to sitemap file.
This is a piece of code
<asp:menu ... >
<StaticItemTemplate>
<%# ((MenuItem)Container.DataItem).Selected ? [Show 'selected'-styled
decoration] : [Show plain-styled decoration] %>
</StaticItemTemplate>
</asp:menu>

I check properties of menu items in my method and based on it decide,
which element should be shown selected.

The problem is when I try to determine this before databinding event,
menu still does not have items and impossible to find out, what should
be selected. When I try to determine this AFTER databinding, it's too
late, because <StaticItemTemplate> already rendered and element is
shown unselected :(
 
A

alexandis

Specifying:
when I CLICK some menu item (i.e. do postback) - everything is ok,
this item is shown selected without any code.
But i also need to select some default menu item on start up, when
just being redirected from login page.
This piece DOESN'T work...
 
A

alexandis

Maybe I should make something like this
((MenuItem)Container.DataItem).Selected ||
IsThisSelected((MenuItem)Container.DataItem) ? ....

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top