Solved

Add an image next to asp:menuitem at runtime

Posted on 2009-04-02
2
238 Views
Last Modified: 2012-05-06
Hi Guys,

I have a menu control on ASPX page and I am adding menuitems to this control during runtime.

My requirement is to display an image next to menuitem, if some condition is true, otherwise render menuitem without any image next to it.

I have tried with setting "ImageUrl"  property of a menuitem, but it doesn't worked.

I appreciate if anyone let me know the answer.

Cheers,
Kiran G

0
Comment
Question by:kirankumar_goura
2 Comments
 
LVL 4

Accepted Solution

by:
mysteriousguy earned 125 total points
ID: 24057517
ImageUrl works in this case. I tried it with the code attached.
Please post an example if there are any problems.

Martin
MenuItem item;
item = new MenuItem("Item Without Image", "ItemWithoutImage");
Menu1.Items.Add(item);
item = new MenuItem("Item With Image", "ItemWithImage", "~/images/red.jpg");
Menu1.Items.Add(item);

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question