Hi Andrew,
As for adding custom attributes to ASP.NET 2.0 Menu control, it is
limited
by the following things:
** the <MenuItem> tag in Menu control is not sub controls, they're just
some property tag which is not directly constructed as a sub control at
runtime, there fore you can not add attributes into "MenuItem" class
instance
** so far the Menu control do not let you directly access the underlying
created MenuItem's actual control instance
One way for you to perform customization on the MenuItem(using template)
is
add your data binding expression with custom functions. e.g.
=======
<StaticItemTemplate>
<%# CallYourCustomFunctionHere( params....) %>
</StaticItemTemplate>
=========
You can pass "Container" or "Container.DataItem" into your c ustom
function
so as to determine the value to return in the custom function. How do you
think?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Andrew Jocelyn" <
[email protected]>
Subject: Menu control Databinding problem using StaticItemTemplate
Date: Mon, 14 Jan 2008 17:43:47 -0000
Hi
How do add custom attributes to a System.Web.UI.WebControls.MenuItem in a
StaticItemTemplate which I have saved in my
SiteMapDataSource file? e.g.
<siteMapNode title="stuff" id="myid">
protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
string id = ((SiteMapNode)e.Item.DataItem)["id"];
if (id != null)
Trace.Write(id);
// add the attribute to the MenuItem
}
I can't see how you can do it with the Menu control. Do I have any other
options which are not too much work to implement?
Thanks
Andrew