Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Thursday, March 29, 2012

newbie: image problems again

hey

asp.net 2.0

my problem is that on a webpage am I trying to dynamically display the image
a user has uploaded. But the webpage doesn't display the image. The browser
displays the standard image telling that image not found / broken image link
etc...

This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName +
".jpeg"));

This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg");

The image exist in that folder

Any suggestions to this error?

JeffHi Jeff,

does this variable "Profile.UserName" really exist when you try to load the
image. Did you place an exception-handler around the loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image. The
browser displays the standard image telling that image not found / broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>


Hey

it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...

any suggestions?

Jeff

"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display the
>image a user has uploaded. But the webpage doesn't display the image. The
>browser displays the standard image telling that image not found / broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>


>
>


Hi Jeff,

I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.

2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....

I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.

- V

Jeff wrote:

Quote:

Originally Posted by

Hey
>
it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>
I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...
>
any suggestions?
>
Jeff
>
>
"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,

does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image. The
browser displays the standard image telling that image not found / broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" + Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>



The path is
C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\BN\Images\Fullsize\test.jpeg

I've checked and path is correct, but the path contains spaces...

I'm not sure about it but maybe the browser need to know if this is a
picture ("image/thumb")?

Jeff

"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,
>
I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.
>
2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....
>
I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.
>
- V
>
Jeff wrote:

Quote:

Originally Posted by

>Hey
>>
>it looks like Profile.UserName is empty...
>But this code doesn't work either:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>>
>I've also tryed this (setting it directly in the source, not the code
>behind):
>src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
>Without any success...
>>
>any suggestions?
>>
>Jeff
>>
>>
>"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
>news:e8elch$p0k$02$1@.news.t-online.com...

Quote:

Originally Posted by

Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the
loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display the
>image a user has uploaded. But the webpage doesn't display the image.
>The
>browser displays the standard image telling that image not found /
>broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>
>
>


>


It is possible that you may need to grant permission to the asp.net
process on that image directory. It might be a problem with the
security.

- V
Jeff wrote:

Quote:

Originally Posted by

The path is
C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\BN\Images\Fullsize\test.jpeg
>
I've checked and path is correct, but the path contains spaces...
>
I'm not sure about it but maybe the browser need to know if this is a
picture ("image/thumb")?
>
>
>
>
Jeff
>
>
>
>
>
"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,

I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.

2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....

I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.

- V

Jeff wrote:

Quote:

Originally Posted by

Hey
>
it looks like Profile.UserName is empty...
But this code doesn't work either:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>
I've also tryed this (setting it directly in the source, not the code
behind):
src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
Without any success...
>
any suggestions?
>
Jeff
>
>
"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
news:e8elch$p0k$02$1@.news.t-online.com...
Hi Jeff,

does this variable "Profile.UserName" really exist when you try to load
the image. Did you place an exception-handler around the
loading-method?

Bye,

--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
hey
>
asp.net 2.0
>
my problem is that on a webpage am I trying to dynamically display the
image a user has uploaded. But the webpage doesn't display the image.
The
browser displays the standard image telling that image not found /
broken
image link etc...
>
This is the code which saves the image to hard drive...:
fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
Profile.UserName
+ ".jpeg"));
>
This is my code for displaying the image, it's in Page_Load event of
webpage:
imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
Profile.UserName + ".jpeg");
>
The image exist in that folder
>
Any suggestions to this error?
>
Jeff
>



I replaced this line:

imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");

with this line

imgPicture.ImageUrl = "~/Images/Fullsize/test.jpeg";

And now it works

Thank you very much for helping me with this. The best thing with this
problem is that I've learned from it -maybe using Server.MapPath isn't
best all the times...

Best Regards!

Jeff

"V" <vaibhav.gadodia@.gmail.comwrote in message
news:1152057813.849114.308260@.m73g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

It is possible that you may need to grant permission to the asp.net
process on that image directory. It might be a problem with the
security.
>
- V
Jeff wrote:

Quote:

Originally Posted by

>The path is
>C:\Documents and Settings\Jeff\My Documents\Visual Studio
>2005\WebSites\BN\Images\Fullsize\test.jpeg
>>
>I've checked and path is correct, but the path contains spaces...
>>
>I'm not sure about it but maybe the browser need to know if this is a
>picture ("image/thumb")?
>>
>>
>>
>>
>Jeff
>>
>>
>>
>>
>>
>"V" <vaibhav.gadodia@.gmail.comwrote in message
>news:1152051114.522719.324780@.a14g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Hi Jeff,
>
I am not sure what your problem is, but try one of these two things:
1. If you are using something like VS.Net, then simply try to locate a
test image using the properties grid of the Image Control. And then try
to run your page and see if it works.
>
2. try printing the path you are trying to assign to the ImageUrl
property by using a Response.Write() from the code behind.
So basically Response.Write(Server.MapPath("~\....
>
I have a feeling you are doing a bit too much in trying to assign a
path to the ImageUrl property.
>
- V
>
Jeff wrote:
>Hey
>>
>it looks like Profile.UserName is empty...
>But this code doesn't work either:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/test.jpeg");
>>
>I've also tryed this (setting it directly in the source, not the code
>behind):
>src='<%# Eval("~/Images/Fullsize/test.jpeg") %>'
>Without any success...
>>
>any suggestions?
>>
>Jeff
>>
>>
>"Matthias Pieroth" <piermat2001@.yahoo.dewrote in message
>news:e8elch$p0k$02$1@.news.t-online.com...
Hi Jeff,
>
does this variable "Profile.UserName" really exist when you try to
load
the image. Did you place an exception-handler around the
loading-method?
>
Bye,
>
--
Matthias Pieroth
www.codegod.de - The Page for .NET-developers
>
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23qlAzL5nGHA.1808@.TK2MSFTNGP02.phx.gbl...
>hey
>>
>asp.net 2.0
>>
>my problem is that on a webpage am I trying to dynamically display
>the
>image a user has uploaded. But the webpage doesn't display the
>image.
>The
>browser displays the standard image telling that image not found /
>broken
>image link etc...
>>
>This is the code which saves the image to hard drive...:
>fullsizeImage.Save(Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName
>+ ".jpeg"));
>>
>This is my code for displaying the image, it's in Page_Load event
>of
>webpage:
>imgPicture.ImageUrl = Server.MapPath("~/Images/Fullsize/" +
>Profile.UserName + ".jpeg");
>>
>The image exist in that folder
>>
>Any suggestions to this error?
>>
>Jeff
>>
>
>
>


>

Newbie: Image button aspect ratio

I have some image buttons which I am dynamically adding from a database. No
problems so far...
However, when it loads the image using IMAGEURL=, it doesn't keep the
original aspect ratio.
Is there a way to keep this without resizing the control?
Many thanks,
David Whitchurch-BennettThe aspect ratio is not affected at all by the ImageURL property. Most
likely you have the height or width of the control set to a value. If you
remove those values from the control, the image will come in at its normal
size, if you want it smaller (but wish to preserve the aspect ratio), then
just set a width or a height for the control but not both.
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>I have some image buttons which I am dynamically adding from a database. No
> problems so far...
> However, when it loads the image using IMAGEURL=, it doesn't keep the
> original aspect ratio.
> Is there a way to keep this without resizing the control?
> Many thanks,
> David Whitchurch-Bennett
>
Thanks for that information. What I have in my app is an image button set to
250 x 250, with a thick border which is all part of the visual theme. That i
s
why I have set the size first. What I want to do is load an image dynamicall
y
in the center of the image button, but keep the image button border the same
size, so the visual theme is preserved.
Is this possible, or will the only way be to place the image button into
another container with a border.
"Scott M." wrote:

> The aspect ratio is not affected at all by the ImageURL property. Most
> likely you have the height or width of the control set to a value. If you
> remove those values from the control, the image will come in at its normal
> size, if you want it smaller (but wish to preserve the aspect ratio), then
> just set a width or a height for the control but not both.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>
>
I think this is more of an issue of having graphics that will fit into a
250x250 space that VS.NET sizing the images for you. Your best bet is to
use a good graphics tool to create images that will fit into that space,
rather than attempt to have VS.NET fit them for you.
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> Thanks for that information. What I have in my app is an image button set
> to
> 250 x 250, with a thick border which is all part of the visual theme. That
> is
> why I have set the size first. What I want to do is load an image
> dynamically
> in the center of the image button, but keep the image button border the
> same
> size, so the visual theme is preserved.
> Is this possible, or will the only way be to place the image button into
> another container with a border.
> "Scott M." wrote:
>
I already have this. I am using a class that I have written to scale down th
e
image first for two reasons.
1. To help the page load faster.
2. To prevent people downloading the full size images (photographic website)
.
Rather than resizing all of my photos, my class takes care of this by
scaling down the image. I pass the maximum width and height, and the image i
s
scaled down to fit and it maintains the aspect ratio.
When I put the scaled down image into the button, it stetches it out to fit
in both dimensions.
I guess I just asumed there would be a way to display the image without
stretching it out. I can pad the extra pixels in the function to return a
square image if that is a better way.
Thanks for your help. ASP.NET is quite different to what I am used to, but I
am getting there!
"Scott M." wrote:

> I think this is more of an issue of having graphics that will fit into a
> 250x250 space that VS.NET sizing the images for you. Your best bet is to
> use a good graphics tool to create images that will fit into that space,
> rather than attempt to have VS.NET fit them for you.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
>
>
How about putting the image into an image control (not a button image
control) and overlaying the image control on top of your button control?
"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:C9567572-5BBC-4DE9-83C9-44BE4F3465F4@.microsoft.com...
>I already have this. I am using a class that I have written to scale down
>the
> image first for two reasons.
> 1. To help the page load faster.
> 2. To prevent people downloading the full size images (photographic
> website).
> Rather than resizing all of my photos, my class takes care of this by
> scaling down the image. I pass the maximum width and height, and the image
> is
> scaled down to fit and it maintains the aspect ratio.
> When I put the scaled down image into the button, it stetches it out to
> fit
> in both dimensions.
> I guess I just asumed there would be a way to display the image without
> stretching it out. I can pad the extra pixels in the function to return a
> square image if that is a better way.
> Thanks for your help. ASP.NET is quite different to what I am used to, but
> I
> am getting there!
> "Scott M." wrote:
>
I ran into the same problem... I found an easy to solution to prevent scalin
g is to use a hyperlink control and set its imageurl property to the image i
n question.

Newbie: Image button aspect ratio

I have some image buttons which I am dynamically adding from a database. No
problems so far...

However, when it loads the image using IMAGEURL=, it doesn't keep the
original aspect ratio.

Is there a way to keep this without resizing the control?

Many thanks,

David Whitchurch-BennettThe aspect ratio is not affected at all by the ImageURL property. Most
likely you have the height or width of the control set to a value. If you
remove those values from the control, the image will come in at its normal
size, if you want it smaller (but wish to preserve the aspect ratio), then
just set a width or a height for the control but not both.

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>I have some image buttons which I am dynamically adding from a database. No
> problems so far...
> However, when it loads the image using IMAGEURL=, it doesn't keep the
> original aspect ratio.
> Is there a way to keep this without resizing the control?
> Many thanks,
> David Whitchurch-Bennett
Thanks for that information. What I have in my app is an image button set to
250 x 250, with a thick border which is all part of the visual theme. That is
why I have set the size first. What I want to do is load an image dynamically
in the center of the image button, but keep the image button border the same
size, so the visual theme is preserved.

Is this possible, or will the only way be to place the image button into
another container with a border.

"Scott M." wrote:

> The aspect ratio is not affected at all by the ImageURL property. Most
> likely you have the height or width of the control set to a value. If you
> remove those values from the control, the image will come in at its normal
> size, if you want it smaller (but wish to preserve the aspect ratio), then
> just set a width or a height for the control but not both.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
> >I have some image buttons which I am dynamically adding from a database. No
> > problems so far...
> > However, when it loads the image using IMAGEURL=, it doesn't keep the
> > original aspect ratio.
> > Is there a way to keep this without resizing the control?
> > Many thanks,
> > David Whitchurch-Bennett
>
I think this is more of an issue of having graphics that will fit into a
250x250 space that VS.NET sizing the images for you. Your best bet is to
use a good graphics tool to create images that will fit into that space,
rather than attempt to have VS.NET fit them for you.

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> Thanks for that information. What I have in my app is an image button set
> to
> 250 x 250, with a thick border which is all part of the visual theme. That
> is
> why I have set the size first. What I want to do is load an image
> dynamically
> in the center of the image button, but keep the image button border the
> same
> size, so the visual theme is preserved.
> Is this possible, or will the only way be to place the image button into
> another container with a border.
> "Scott M." wrote:
>> The aspect ratio is not affected at all by the ImageURL property. Most
>> likely you have the height or width of the control set to a value. If
>> you
>> remove those values from the control, the image will come in at its
>> normal
>> size, if you want it smaller (but wish to preserve the aspect ratio),
>> then
>> just set a width or a height for the control but not both.
>>
>> "David Whitchurch-Bennett"
>> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>> >I have some image buttons which I am dynamically adding from a database.
>> >No
>> > problems so far...
>>> > However, when it loads the image using IMAGEURL=, it doesn't keep the
>> > original aspect ratio.
>>> > Is there a way to keep this without resizing the control?
>>> > Many thanks,
>>> > David Whitchurch-Bennett
>>>
>>
>
I already have this. I am using a class that I have written to scale down the
image first for two reasons.

1. To help the page load faster.
2. To prevent people downloading the full size images (photographic website).

Rather than resizing all of my photos, my class takes care of this by
scaling down the image. I pass the maximum width and height, and the image is
scaled down to fit and it maintains the aspect ratio.

When I put the scaled down image into the button, it stetches it out to fit
in both dimensions.

I guess I just asumed there would be a way to display the image without
stretching it out. I can pad the extra pixels in the function to return a
square image if that is a better way.

Thanks for your help. ASP.NET is quite different to what I am used to, but I
am getting there!

"Scott M." wrote:

> I think this is more of an issue of having graphics that will fit into a
> 250x250 space that VS.NET sizing the images for you. Your best bet is to
> use a good graphics tool to create images that will fit into that space,
> rather than attempt to have VS.NET fit them for you.
> "David Whitchurch-Bennett"
> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
> > Thanks for that information. What I have in my app is an image button set
> > to
> > 250 x 250, with a thick border which is all part of the visual theme. That
> > is
> > why I have set the size first. What I want to do is load an image
> > dynamically
> > in the center of the image button, but keep the image button border the
> > same
> > size, so the visual theme is preserved.
> > Is this possible, or will the only way be to place the image button into
> > another container with a border.
> > "Scott M." wrote:
> >> The aspect ratio is not affected at all by the ImageURL property. Most
> >> likely you have the height or width of the control set to a value. If
> >> you
> >> remove those values from the control, the image will come in at its
> >> normal
> >> size, if you want it smaller (but wish to preserve the aspect ratio),
> >> then
> >> just set a width or a height for the control but not both.
> >>
> >> "David Whitchurch-Bennett"
> >> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
> >> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
> >> >I have some image buttons which I am dynamically adding from a database.
> >> >No
> >> > problems so far...
> >> >> > However, when it loads the image using IMAGEURL=, it doesn't keep the
> >> > original aspect ratio.
> >> >> > Is there a way to keep this without resizing the control?
> >> >> > Many thanks,
> >> >> > David Whitchurch-Bennett
> >> >>
> >>
> >>
>
How about putting the image into an image control (not a button image
control) and overlaying the image control on top of your button control?

"David Whitchurch-Bennett"
<DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
news:C9567572-5BBC-4DE9-83C9-44BE4F3465F4@.microsoft.com...
>I already have this. I am using a class that I have written to scale down
>the
> image first for two reasons.
> 1. To help the page load faster.
> 2. To prevent people downloading the full size images (photographic
> website).
> Rather than resizing all of my photos, my class takes care of this by
> scaling down the image. I pass the maximum width and height, and the image
> is
> scaled down to fit and it maintains the aspect ratio.
> When I put the scaled down image into the button, it stetches it out to
> fit
> in both dimensions.
> I guess I just asumed there would be a way to display the image without
> stretching it out. I can pad the extra pixels in the function to return a
> square image if that is a better way.
> Thanks for your help. ASP.NET is quite different to what I am used to, but
> I
> am getting there!
> "Scott M." wrote:
>> I think this is more of an issue of having graphics that will fit into a
>> 250x250 space that VS.NET sizing the images for you. Your best bet is to
>> use a good graphics tool to create images that will fit into that space,
>> rather than attempt to have VS.NET fit them for you.
>>
>> "David Whitchurch-Bennett"
>> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> news:B4825793-D8BD-476C-96B8-9E63062C1B6F@.microsoft.com...
>> > Thanks for that information. What I have in my app is an image button
>> > set
>> > to
>> > 250 x 250, with a thick border which is all part of the visual theme.
>> > That
>> > is
>> > why I have set the size first. What I want to do is load an image
>> > dynamically
>> > in the center of the image button, but keep the image button border the
>> > same
>> > size, so the visual theme is preserved.
>>> > Is this possible, or will the only way be to place the image button
>> > into
>> > another container with a border.
>>> > "Scott M." wrote:
>>> >> The aspect ratio is not affected at all by the ImageURL property.
>> >> Most
>> >> likely you have the height or width of the control set to a value. If
>> >> you
>> >> remove those values from the control, the image will come in at its
>> >> normal
>> >> size, if you want it smaller (but wish to preserve the aspect ratio),
>> >> then
>> >> just set a width or a height for the control but not both.
>> >>
>> >> "David Whitchurch-Bennett"
>> >> <DavidWhitchurchBennett@.discussions.microsoft.com> wrote in message
>> >> news:11381908-84A6-467F-99A3-B274561AA68D@.microsoft.com...
>> >> >I have some image buttons which I am dynamically adding from a
>> >> >database.
>> >> >No
>> >> > problems so far...
>> >>> >> > However, when it loads the image using IMAGEURL=, it doesn't keep
>> >> > the
>> >> > original aspect ratio.
>> >>> >> > Is there a way to keep this without resizing the control?
>> >>> >> > Many thanks,
>> >>> >> > David Whitchurch-Bennett
>> >>> >>
>> >>
>> >>
>>
>>
>

newbie: load image from db + Repeater

hey
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" /> )
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...te.aspx

Monday, March 26, 2012

newbie: load image from db + Repeater

hey

asp.net 2.0

With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.

I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" />)

This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}

The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!

In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...

Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event

Any ideas how I should pass over such a parameter?

Jeffhello Jeff

you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.

on this page is a similar example, though uses a GridView instead, but
logically it's the same

http://authors.aspalliance.com/aspx...inaryWrite.aspx

Saturday, March 24, 2012

Newbie: Selecting image from separate aspx page

I have a form where the user can select an image filename. Clearly it
would be better to allow them to select the image itself rather than key
in the filename.

So, I have a server side directory with the available images. And I have
a page which shows the images as ImageButtons.

My question is: What's the best way to link the two?

Should MyForm.aspx redirect to ImageList.aspx passing "MyForm" in the
query string so that ImageList knows where to redirect back to? It works
but it seems a bit convoluted so I think it must be wrong.

How do you solve this when basically you want to pick from a list of
things which aren't on the calling page?

Hope this makes sense.

In the desktop app environment I'd just open a dialog box. what is the
asp.net paradigm?You could simulate a dialog box by using window.open("ImageBox.aspx")
and then add some javascript in the onclick of the Select Button in
the ImageBox codebehind, which
- sets the image in the calling page (window.opener.getElementByID...)
- closes the imagebox window

So - mainly you have to deal with some javascript and DHTML

As to your original question: For easy pageflows I just put the
refering
page in the session/context items/request, which is not elegant, but
simple.
Alternatively you can implement a pageflow manager which can take
care of more complex navigations. Also worth looking at is
Server.Execute instead of redirect or transfer (and having a refering
page property defined in a page base class). There are really
a lot of options here and it is up to your preferences and requirements
to decide which one you want to go with.

-Stefan

Newbie: Selecting image from separate aspx page

I have a form where the user can select an image filename. Clearly it
would be better to allow them to select the image itself rather than key
in the filename.
So, I have a server side directory with the available images. And I have
a page which shows the images as ImageButtons.
My question is: What's the best way to link the two?
Should MyForm.aspx redirect to ImageList.aspx passing "MyForm" in the
query string so that ImageList knows where to redirect back to? It works
but it seems a bit convoluted so I think it must be wrong.
How do you solve this when basically you want to pick from a list of
things which aren't on the calling page?
Hope this makes sense.
In the desktop app environment I'd just open a dialog box. what is the
asp.net paradigm?You could simulate a dialog box by using window.open("ImageBox.aspx")
and then add some javascript in the onclick of the Select Button in
the ImageBox codebehind, which
- sets the image in the calling page (window.opener.getElementByID...)
- closes the imagebox window
So - mainly you have to deal with some javascript and DHTML
As to your original question: For easy pageflows I just put the
refering
page in the session/context items/request, which is not elegant, but
simple.
Alternatively you can implement a pageflow manager which can take
care of more complex navigations. Also worth looking at is
Server.Execute instead of redirect or transfer (and having a refering
page property defined in a page base class). There are really
a lot of options here and it is up to your preferences and requirements
to decide which one you want to go with.
-Stefan
Thanks Stefan.
I guess the session is a better place rather than clogging up the
querystring. I think I need a bit of practise to get into Web way of
doing things.
Colin
Stefan wrote:
> You could simulate a dialog box by using window.open("ImageBox.aspx")
> and then add some javascript in the onclick of the Select Button in
> the ImageBox codebehind, which
> - sets the image in the calling page (window.opener.getElementByID...)
> - closes the imagebox window
> So - mainly you have to deal with some javascript and DHTML
> As to your original question: For easy pageflows I just put the
> refering
> page in the session/context items/request, which is not elegant, but
> simple.
> Alternatively you can implement a pageflow manager which can take
> care of more complex navigations. Also worth looking at is
> Server.Execute instead of redirect or transfer (and having a refering
> page property defined in a page base class). There are really
> a lot of options here and it is up to your preferences and requirements
> to decide which one you want to go with.
> -Stefan
>