ASP CSS Friendly Control Menu Bug has a bug when you click on one menu item it's not firing MenuItemClick event ..
after hours of work found the soulution.
Replace the MenuAdapter.cs BuildItem() function with this
private void BuildItem(MenuItem item, HtmlTextWriter writer)
{
Menu menu = Control as Menu;
if ((menu != null) && (item != null) && (writer != null))
{
writer.WriteLine();
writer.WriteBeginTag("li");
writer.WriteAttribute("class", item.ChildItems.Count > 0 ? "AspNet-Menu-WithChildren" : "AspNet-Menu-Leaf");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
if (item.NavigateUrl.Length > 0)
{
writer.WriteBeginTag("a");
writer.WriteAttribute("href", Page.ResolveUrl(item.NavigateUrl));
writer.WriteAttribute("class", "AspNet-Menu-Link");
if (item.Target.Length > 0)
{
writer.WriteAttribute("target", item.Target);
}
if (item.ToolTip.Length > 0)
{
writer.WriteAttribute("title", item.ToolTip);
}
else if (menu.ToolTip.Length > 0)
{
writer.WriteAttribute("title", menu.ToolTip);
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
}
else
{
// Modified here... add a self refering link back to the menu
writer.WriteBeginTag("a");
writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(menu, "b" + item.ValuePath.Replace(menu.PathSeparator.ToString(), "\\"), true));
writer.WriteAttribute("class", "AspNet-Menu-Link");
if (item.Target.Length > 0)
{
writer.WriteAttribute("target", item.Target);
}
if (item.ToolTip.Length > 0)
{
writer.WriteAttribute("title", item.ToolTip);
}
else if (menu.ToolTip.Length > 0)
{
writer.WriteAttribute("title", menu.ToolTip);
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
}
if (item.ImageUrl.Length > 0)
{
writer.WriteBeginTag("img");
writer.WriteAttribute("src", Page.ResolveUrl(item.ImageUrl));
writer.WriteAttribute("alt", item.ToolTip.Length > 0 ? item.ToolTip : (menu.ToolTip.Length > 0 ? menu.ToolTip : item.Text));
writer.Write(HtmlTextWriter.SelfClosingTagEnd);
}
writer.Write(item.Text);
if (item.NavigateUrl.Length > 0)
{
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("a");
}
else
{
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("a");
//writer.WriteEndTag("span");
}
if ((item.ChildItems != null) && (item.ChildItems.Count > 0))
{
BuildItems(item.ChildItems, false, writer);
}
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("li");
}
}
Wednesday, July 22, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment