Sorry so long... I meant to say thanks for the adapter suggestion... I definitely never would have solved it w/o that.
After I applied the adapter, I was able to modify it slightly by giving the required elements an id:
private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
{
if (items.Count > 0)
{
writer.WriteLine();
writer.WriteBeginTag("ul");
if (isRoot)
{
writer.WriteAttribute("class", "AspNet-Menu");
writer.WriteAttribute("id", "ulMenu");
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
foreach (MenuItem item in items)
{
BuildItem(item, writer);
}
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("ul");
}
}
private void BuildItem(MenuItem item, HtmlTextWriter writer)
{
Menu menu = Control as Menu;
if ((menu != null) && (item != null) && (writer != null))
{
writer.WriteLine();
writer.WriteBeginTag("li");
string theClass = (item.ChildItems.Count > 0) ? "AspNet-Menu-WithChildren" : "AspNet-Menu-Leaf";
string selectedStatusClass = GetSelectStatusClass(item);
if (!String.IsNullOrEmpty(selectedStatusClass))
{
theClass += " " + selectedStatusClass;
}
writer.WriteAttribute("class", theClass);
if (item.Parent == null)
{
writer.WriteAttribute("id", "liMenu");
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
Then, in the .cs file of the page containing the menu, I could the number of menu items and used some javascript code to search for the tags assigned above and to resize each menu element. I had to use the 99.9 b/c using 100% always pushed the last menu item down a row in Firefox... (strSelectedPageIDs is a comma-separated string of distinct page ID's currently included in the menu - searching for where the ParentPageID is not in that string returns an array of datarows with one row corresponding to each parent node on the menu)
DataRow
[] drs = ds.Tables["dstPages"].Select("ParentPageID NOT IN (" + strSelectedPageIDs + ")");
if (drs.Length != 3 && drs.Length != 0) //Widths are 33% by default... don't *** with it if you don't have to...
{
double intNewWidth = (99.9 / (double)drs.Length);
string strChangeMenuWidth = "<script type='text/javascript'>";
strChangeMenuWidth += "var ulMenus = document.getElementById('ulMenu');";
strChangeMenuWidth += "var liMenus = document.getElementsByTagName('li');";
strChangeMenuWidth += "for (i=0;i<liMenus.length;i++)";
strChangeMenuWidth += "{";
strChangeMenuWidth += "if (liMenus[i].id == 'liMenu')";
strChangeMenuWidth += "{";
strChangeMenuWidth += "liMenus[i].style.width='" + intNewWidth.ToString() + "%';";
strChangeMenuWidth += "}";
strChangeMenuWidth += "}";
strChangeMenuWidth += "</script>";
Page.ClientScript.RegisterStartupScript(typeof(Page), "ChangeMenuWidth", strChangeMenuWidth);
}