|
Rank: Advanced Member Groups: Member
Joined: 7/2/2008 Posts: 35
|
How do I set the properties such as background color, side image, etc when creating a menu from an XML file.
Eg <Category title="Hazards" > <Category title ="List" url="~/menusupport/menu_select.aspx?ID=Reports_List_Hazards" /> <Category title ="Hazards Notice" url="~/menusupport/menu_select.aspx?ID=Reports_List_Accidents" /> </Category> </Category/>
I want to attach a side image to each of the menu items, and change the background colors
I can do this I the menu builder, but can't see how to do it in the XML file.
I have many different menus according to the user-role.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Please see here for more details (looking for populating from XmlDataSource): http://www.essentialobjects.com/doc/1/menucommon/databinding/populate_datasource.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/2/2008 Posts: 35
|
Thanks, but I'm still unclear. There only seems to be four attributes recognised in the <Category> tag.
For example, in this snippet, I want to put an image at the side of the HOME item. Could you give me the syntax, please?
<Category title="Home" url="~/Menusupport/menu_select.aspx?ID=System_Home"> </Category>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, For that you need to use the DataBinding object. See here for more details: http://www.essentialobjects.com/ViewDoc.aspx#menudatabindingYou will need to replace the Property and DataField of the DataBinding object given in the example with your own values. For example, if you want to transfer your url attribute in your XML to the MenuItem's LeftIcon.Url property, you would use a DataBinding object like this:
Code: HTML/ASPX
<eo:DataBinding Property="LeftIcon-Url" DataField="@url">
</eo:DataBinding>
Hope this helps. Please let us know if you still have any questions. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/2/2008 Posts: 35
|
I think I am just going to admit defeat on this one. EO tag is not recognised in the XML file.
My menu is in a master page, and is populated by very different top-level menu items according to the logged-in user type.
For example, not all of them have the "PEOPLE" top-level item, so I can't hard code the image in the HTML on the master page.
Is there any way I can modify the menu through vb code after the menu has been populated from the xml file?
f not, I will just un with a menu without images.
Regards, and thanks, your help is appreciated. This is the first time in 6 years that I have had a 'serious' challenge with your products, which are otherwise very comprehensive and easy to use.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, I am not sure if I understand what you meant by "EO tag is not recognized in the XML file" correctly. You will never use eo tags in your XML files. You use eo tag in your .aspx file. The eo:DataBinding is what you put in your .aspx to instruct our Menu control to read a specific attribute in your XML file into a specific menu item property. If you want to modify the icon with code, you can do something like this:
Code: Visual Basic.NET
Menu1.Items(0).LeftIcon.Url = your_url
This will modify the first top level item's left icon. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 7/2/2008 Posts: 35
|
hmmm... I am definitely missing something here.
It seems that I cannot change the menu once the XML has been executed.
For example, the following snippet.... Menu1.XmlFile = "../MenuSupport/accountOwner.xml" Menu1.Items.Clear() Menu1.Items.Add("Menu Item 1") Menu1.Items(0).LeftIcon.Url = "../images/people.jpg"
...... this displays the menu defined in the XML file, and the following three lines, although executed by the code, do nothing.
But if I remove the first line (ie comment out the XML reference) then the other three lines execute properly. Also, I can display my icon !
So my solution is not to use XML, but to write code which assembled the menu I want using VB.
Is this a known bug, or is there another property I need to set, eg "allow menu updating after XML ?????"
Regards
V
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Make sure you do this:
Code: Visual Basic.NET
Menu1.XmlFile = "../MenuSupport/accountOwner.xml"
Menu1.DataBind()
Note the DataBind call on the second line. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/2/2008 Posts: 35
|
Bingo ! Yes, I can now use XML and then add my icons.
Signing out on this one, many many thanks.
There are heaps of features in your products, but it is 'fitting all the bits together' that give people like me, working on their own, the greatest difficulty. We love examples !!
Regards
V
|
|