473,414 Members | 1,980 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,414 software developers and data experts.

Theme + asp:menu + ImageUrl = Help

Ben
Hi, I'm using images in my menu control. I have my menu setup based on this
example:
http://msdn2.microsoft.com/en-US/lib...ld(VS.80).aspx

I have a theme and right now, the theme structure looks like...

App_Themes
--Authenticated
----Images
------Menu
--------Item.jpg
--------Item2.jpg
--------Item3.jpg
--------etc.jpg

In my menu.xml file I have my nodes defined as follows:
<MapHomeNode NavigateUrl="~/ProjectBackground/default.aspx"
ImageUrl="~/App_Themes/Authenticated/Images/Menu/application_home.png"
Title="Project Background"
Description="Project Background"
ToolTip="Project Background">
</MapHomeNode>

My problem is that I can't seem to get the ImageUrl to funcion with the
themes. I've tried:
ImageUrl="Images/Menu/application_home.png"
ImageUrl="/Images/Menu/application_home.png"
ImageUrl="~/Images/Menu/application_home.png"

I would expect the first one to work, but it doesn't!

Both of these work just fine (they both render the same way)
ImageUrl="~/App_Themes/Authenticated/Images/Menu/application_home.png"
ImageUrl="App_Themes/Authenticated/Images/Menu/application_home.png"

I feel that I'm well versed in 1.1, but 2.0 remains egnigmatic. I'm sure
that I'm overlooking the obvious, would someone please help me out?

Thanks,
Mar 14 '06 #1
4 3380
Hi Bennett,

Welcome to the MSDN newsgroup.

Regarding on the Menu control with databinding xml source and Theme
question, based on my understanding, if you're wantting to both use XML
DataSource's attribute as databind source for ImageUrl , but also use Theme
(folder) specific path , that is not supported currently. This is because
the Theme specific path is only available to those setting which is defined
in the Theme file(skin file) which is compiled into certain control at
runtime (at the initialize time). For databinding , it occur after the
theme is applied, so it won't be able to utilize the Theme specific path
interpreting.

I've just performed some tests on my side and we can make our Node use the
theme specific path through those default properties instead of databinding
field(since these properties can be set in the skin file that can be
compiled at theme initialize time). For example:

========in skin file=================

<asp:Menu SkinID="Main" runat="server" >
<DataBindings>
<asp:MenuItemBinding DataMember="MapHomeNode" FormatString="({0})"

Target="_self" TextField="Title" ToolTipField="ToolTip"
ValueField="Description"
ImageUrl="Images/Menu/item.jpg"
/>
<asp:MenuItemBinding DataMember="MapNode" FormatString="[{0}]"
Target="_blank" TextField="Title"
ToolTipField="ToolTip" ValueField="Description"
Depth="1" ImageUrl="Images/Menu/item1.jpg"/>
<asp:MenuItemBinding DataMember="MapNode" FormatString="|{0}|"
Target="_blank" TextField="Title"
ToolTipField="ToolTip" ValueField="Description"
Depth="2" ImageUrl="Images/Menu/item2.jpg"/>
</DataBindings>
</asp:Menu>
=============================

======== in aspx page=========

<asp:Menu ID="Menu1" runat="server" DataSourceID="XmlDataSource1"
SkinID="Main">

</asp:Menu>
=========================

We can see that we use "ImageUrl" property to specify theme specific path
for the Node and let other field still utilize databinding fields from xml
datasource.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 14 '06 #2
Ben
Ok, since dynamically configured ImageUrl's cannot be themed and I'm new to
2.0, is it possible to determine the current Theme directory to perform a
manual string concat in MenuItemDataBound?
Mar 14 '06 #3
DWS
Ben,
How about trying Skins?

DWS

"Ben" wrote:
Ok, since dynamically configured ImageUrl's cannot be themed and I'm new to
2.0, is it possible to determine the current Theme directory to perform a
manual string concat in MenuItemDataBound?

Mar 14 '06 #4
Thanks for your response Ben,

I think your idea is really cool, I did missed the "MenuItemDataBound"
event, I've tested it and we can do this as long as we know the sub folder
structure under each Theme's folder. And the page's current Theme can be
got through Page.Theme property. For example, we can add our code in Menu's
MenuItemDatabound event handler as below:

=====================

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
string path;

switch(e.Item.Depth)
{
case 0:
path = Page.ResolveUrl("~/App_Theme/" +Page.Theme +
"/Images/Menu/item.jpg");
break;
case 1:
path = Page.ResolveUrl("~/App_Theme/" +Page.Theme +
"/Images/Menu/item1.jpg");
break;
case 2:
path = Page.ResolveUrl("~/App_Theme/" +Page.Theme +
"/Images/Menu/item2.jpg");
break;

e.Item.ImageUrl = path;
}

}
======================

BTW, you can also consider the approach in my last reply which make each
Theme's MenuItem databinding setting in the Theme also.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 15 '06 #5

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

Similar topics

2
by: Uriah | last post by:
I have a sort of critical problem that is driving users nuts. My site works fine when running over HTTP but when I switch to HTTPS, an error is generated every time a user mouses over one of the...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
2
by: Kevin L. Kitchens | last post by:
Howdy... Been toying the the asp:menu object in order to dump the manually generated menu I've been using, however, I cannot seem to get the coloring to work properly. First off, what CSS...
13
by: Smith | last post by:
Hello, Does someone know a link to an example of customization of an asp:menu? Many thansk in advance. S
0
by: jobs | last post by:
Hi. I have a menu horizontal on the top. I figured out that if I set this property the black arrow on parent items goes away.. StaticEnableDefaultPopOutImage="False" However, the item is...
3
by: kenny bones | last post by:
Hi! I'm currently working on a menu which is based on CSS and is listed with <li> tags. The CSS code looks like this: #nav { position: absolute; top: 101px; left: 390px; list-style: none;...
3
by: win | last post by:
I've create menu in a webform. <asp:Menu ID="Menu1" runat="server" CssClass="toolbar" Orientation="Horizontal"> <Items> <asp:MenuItem Text="Master" Value="Master"> <asp:MenuItem...
0
by: Mark B | last post by:
I have an asp:Menu control in vertical drop-down mode, a portion as displayed: Can anyone tell me how to get Community correctly aligned with Support? Also how do I put a bit of a gap...
0
by: nzkks | last post by:
Hi, I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005 In a asp.net page, I have two multiview controls each has 2 views & its corresponding 2 menu items named Metric &...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.