Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Fri, 3 Oct 2008 23:15:28 +0200,    group: microsoft.public.dotnet.framework.aspnet        back       


'Image' does not contain a definition for 'ImageUrl'   
hi

asp.net 2.0

I get this compile error:
'Image' does not contain a definition for 'ImageUrl'

Image image = (Image)e.Item.FindControl("img");
image.ImageUrl = "~/image.png";

the compile error is on the second line above. This is strange. This used to 
compile without problem. But it started after I had created a separate 
folder for storing masterpages (I moved the masterpages and updated link to 
them in each .aspx). Also created a new masterpage, by copying the markup of 
another masterpage. Then the compile errror arrived.

any suggestions?
date: Fri, 3 Oct 2008 23:15:28 +0200   author:   Jeff AM

Re: 'Image' does not contain a definition for 'ImageUrl'   
Probably because it is not sure which image you mean? Unless you specify the 
namespace, the compiler can pull the wrong image class.

Instead try using

System.Web.UI.WebControls.Image image = 
(System.Web.UI.WebControls.Image)e.Item.FindControl("img");

This ensures you're getting the correct image object.

Hope this helps,
Mark Fitzpatrick

"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message 
news:#jkBH1ZJJHA.1308@TK2MSFTNGP02.phx.gbl...
> hi
>
> asp.net 2.0
>
> I get this compile error:
> 'Image' does not contain a definition for 'ImageUrl'
>
> Image image = (Image)e.Item.FindControl("img");
> image.ImageUrl = "~/image.png";
>
> the compile error is on the second line above. This is strange. This used 
> to compile without problem. But it started after I had created a separate 
> folder for storing masterpages (I moved the masterpages and updated link 
> to them in each .aspx). Also created a new masterpage, by copying the 
> markup of another masterpage. Then the compile errror arrived.
>
> any suggestions?
>
date: Fri, 3 Oct 2008 16:37:37 -0500   author:   Mark Fitzpatrick

Re: 'Image' does not contain a definition for 'ImageUrl'   
"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message 
news:%23jkBH1ZJJHA.1308@TK2MSFTNGP02.phx.gbl...

> I get this compile error:
> 'Image' does not contain a definition for 'ImageUrl'
>
> Image image = (Image)e.Item.FindControl("img");
> image.ImageUrl = "~/image.png";
>
> the compile error is on the second line above. This is strange. This used 
> to compile without problem. But it started after I had created a separate 
> folder for storing masterpages (I moved the masterpages and updated link 
> to them in each .aspx). Also created a new masterpage, by copying the 
> markup of another masterpage. Then the compile errror arrived.
>
> Any suggestions?

Firstly, are you absolutely that the first line has worked?

What does image.GetType() return?

If you set a breakpoint on the second line and then inspect the image 
variable in the locals window or the immediate window, what properties does 
IntelliSense reveal...?


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
date: Fri, 3 Oct 2008 22:37:53 +0100   author:   Mark Rae [MVP]

Re: 'Image' does not contain a definition for 'ImageUrl'   
Firstly, are you absolutely that the first line has worked?
Yes, I've just commented out this line: image.ImageUrl = "~/image.png"; and 
now it compiles
(but no image is displayed)

What does image.GetType() return?
"System.Web.UI.WebControls.Image"

what properties does IntelliSense reveal
it reveals ImageUrl

I don't think the problem is here, but somewhere else maybe. I've executed 
this code many times this evening without getting that compile error. The 
problem started after I've reorganized the masterpages.. well, I don't 
know.. I'm confused here.

part of markup of default.aspx: MasterPageFile="~/Masters/Content.master"
and before I moved the masterpage it was: MasterPageFile="Content.master"
I don't see how that can make the problem

any ideas?
date: Fri, 3 Oct 2008 23:55:05 +0200   author:   Jeff AM

solved   
I just applied what Mark Fitzpatrick suggested and now it works!
date: Sat, 4 Oct 2008 00:01:02 +0200   author:   Jeff AM

thank you, you solved it   
Hi

I applied what you suggested and it solved the problem, hurray ;)

thanks you
date: Sat, 4 Oct 2008 00:03:36 +0200   author:   Jeff AM

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us