473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

In Menu Control's item collection, setting .Selected=false doesn't work if children present

I put in the code below to disable self links in a menu control in a "master" page.

It works properly if the top-level menu item has no children, but both ..Selected = false and .NavigateUrl = null are ignored if the top-level menu item has nested (child) menu items.

This looks like a bug to me, and the documentation for .Selected suggests that it should be possible to disable a higher-level item while leaving the lower levels active.

Is there something possibly about doing this in PreRender that is letting the menu control ignore the settings? Or could the child entries somehow be re-invigorating the top-level menu items?

---Wayne

void Page_PreRender(object sender, EventArgs e)
{
// Disable self links (this page == NavigateUrl)

bool bFirstTime = false;
string [] allPaths;
string [] PathParts;
int i;

MenuItemCollection items = idcMasterMenu.Items;

PathParts = Request.Path.Split(new char[] {'/'}) ;

allPaths = (string [])(Session["AllMenuUrls"]);
if (allPaths == null)
{
bFirstTime = true;
allPaths = new string[items.Count];
}
for (i=0; i < items.Count; i++)
{
if (bFirstTime)
allPaths[i] = items[i].NavigateUrl; // be able to restore if nulled out
if (items[i].NavigateUrl.ToLower().IndexOf(PathParts[PathParts.Length-1].ToLower()) -1)
{
items[i].Selectable = false;
items[i].NavigateUrl = null;
}
else
{
items[i].Selectable = true;
items[i].NavigateUrl = allPaths[i]; // restore from saved values
}
}
if (bFirstTime)
Session["AllMenuUrls"] = allPaths;

} // PreRender

Oct 13 '06 #1
0 1446

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matthew Hanna | last post by:
Hello All! I have a control that just acts on its own to save various properties concerning the form it is placed on. When the form unloads the control saves the current properties including...
2
by: Dave | last post by:
Hi I have a Xml Web Server control on my page <asp:Xml id=Xml1 runat="server" EnableViewState="True"></asp:Xml> I'm doing a transform as follows System.Xml.XmlDocument doc = new...
6
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
9
by: fh | last post by:
Hello! I use a that I include in code behind in a placeholder in page_load: ----------------- PlaceHolder2.Controls.Clear(); _DowntimeDetail= new MES.ascx.DowntimeDetails();...
1
by: Joe Ciaramitaro | last post by:
I have an application that I was trying to convert to vb.net which contains the msscript object to call custom perl scripts which msscript does great. After converting to .net the control doesn't...
0
by: Randy Smith | last post by:
Hi All, My menu control doesn't "dropdown". The "Home" menu item doesn't appear, nor does the "Jobs" item. And, the 2nd group (Labor and Materials) in web.sitemap doesn't appear at all. The...
15
by: Ofer Zelig | last post by:
I'll describe the simplest situation of the problem. I have a simple Web User Control which only contains a: <div id="bla" runat="server" /. I dynamically add it to a page, by performing: ...
4
by: noddy | last post by:
I have a select element containing a list of names. I also have a button to enable the user to enter a new name. When the user clicks the new name button I want to any option shown as selected to...
2
JustRun
by: JustRun | last post by:
Hi, I'm developing a web application using ASP.NET2.0 with C#, I have tried to use custom validation controls to validate my forms, it worked very well in the English language , but when i test it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.