converting this code to C#, how??

J

Jeff

Dear reader!

ASP.NET 2.0

How should this line with vb.net code:
e.Item.ImageUrl = CType(e.Item.DataItem, SiteMapNode)("ImageUrl");
be as C#?????

I want to put the code into MenuItemDataBound(object sender, MenuEventArgs
e)
eventhandler.

I came across this vb.net code on the web, but I'm programming in C# so I
need to convert it into C# for to be able to use it

Any suggestions?

Jeff
 
J

Jeff

Hmm, that gives me this error:
System.Web.UI.WebControls.MenuItem.DataItem' is a 'property' but is used
like a 'method'
 
M

Mark Fitzpatrick

Try

Normally, you would do this.

e.Item.ImageUrl = ((SiteMapNode) e.Item.DataItem).ImageUrl;

but the sitemapnode object doesn't have an ImageUrl property so I'm assuming
it's an attribute.

e.Item.ImageUrl = ((SiteMapNode) e.Item.DataItem).Attributes["ImageUrl"];
 
G

Guest

(via Instant C#):
e.Item.ImageUrl = ((SiteMapNode)e.Item.DataItem)["ImageUrl"];

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top