473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

'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?
Oct 3 '08 #1
5 3853
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.FindContro l("img");

This ensures you're getting the correct image object.

Hope this helps,
Mark Fitzpatrick

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:#j**************@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?
Oct 3 '08 #2
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:%2****************@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

Oct 3 '08 #3
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?
Oct 3 '08 #4
I just applied what Mark Fitzpatrick suggested and now it works!
Oct 3 '08 #5
Hi

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

thanks you
Oct 3 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Nick | last post by:
I have the following code, and it works well on Mozilla 1.6. (However, the image src property cannot be set on Mozilla 1.2.1). Unfortunately, all the code: document.images.itemImage.src =...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
1
by: Jim Hammond | last post by:
Does a WebControls.Image object actually contain an image, and if so, how can I get it? As far as I can tell, the WebControls.Image class does not contain the image itself. It seems to only...
3
by: Jake | last post by:
I am a beginner in C# and web controls. I need a way to load an image which is stored in an Access (mdb) field into an Image control added at runtime. I get the image (jpg format) dynamically at...
1
by: R.A.M. | last post by:
Hello, Could you help me please with a problem concerning handling at server asp:Images? I have <asp:Image ID="DotNETImage" ImageUrl="Images/DotNET_360x280.jpeg" AlternateText="Microsoft .NET...
3
by: Thomas Satzinger | last post by:
Hallo., i just encounterd a strange thing which i cannot resolve. I am saving a bitmap created in memory to the asp temp folder (asp.net 2.0) this works fine, and i donīt want to create an...
2
by: rockdale | last post by:
I believe this must be a very sample question. I have a image dir under myWebsite (myWebSite is the root dir of my web appl) I have an ascx file under myWebsite/userControls in the c# of...
4
by: Deere | last post by:
When I try to take a database field and change it with a function and return it...it will not display the image. The "Imageurl" does not convert to "src=" but stays as ImageUrl. id=Image2 will...
2
by: GD | last post by:
I'm trying to bind (display) a SQL column to an <asp:image control. I was under the impression that this could be achieved my pointing the ImageURL to the databound column but it doesn't seem to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.