converting this code to C#, how??

  • Thread starter Thread starter Jeff
  • Start date Start date
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
 
Hmm, that gives me this error:
System.Web.UI.WebControls.MenuItem.DataItem' is a 'property' but is used
like a 'method'
 
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"];
 
(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
 
Back
Top