Groups | Blog | Home
all groups > asp.net > february 2007 >

asp.net : converting this code to C#, how??



David Anton
2/22/2007 4:36:08 PM
(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


[quoted text, click to view]
Scott M.
2/22/2007 5:23:10 PM
e.Item.ImageUrl = (SiteMapNode) e.Item.DataItem("ImageUrl");




[quoted text, click to view]

Mark Fitzpatrick
2/22/2007 5:30:23 PM
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"];

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

[quoted text, click to view]

Jeff
2/22/2007 11:17:35 PM
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

Jeff
2/22/2007 11:33:44 PM
Hmm, that gives me this error:
System.Web.UI.WebControls.MenuItem.DataItem' is a 'property' but is used
like a 'method'



[quoted text, click to view]

AddThis Social Bookmark Button