469,282 Members | 2,000 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Swapping Image Url

In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>

In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the
client by the JavaScript?

Thanks!

Nov 18 '05 #1
5 2115
After postback, the value of ImageUrl is coming from the control's ViewState.

One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.

"Guadala Harry" wrote:
In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>

In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the
client by the JavaScript?

Thanks!

Nov 18 '05 #2
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
After postback, the value of ImageUrl is coming from the control's ViewState.
One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.

"Guadala Harry" wrote:
In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>

In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the
client by the JavaScript?

Thanks!

Nov 18 '05 #3
Can you make the code in your codebehind only execute the first time it
executes? i.e.

if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
After postback, the value of ImageUrl is coming from the control's

ViewState.

One solution would be to set the value of a hidden field when you set the image's src attribute. The value of the hidden field will get posted back correctly.

"Guadala Harry" wrote:
In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>

In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the client by the JavaScript?

Thanks!


Nov 18 '05 #4
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but
issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).

Thanks anyway.
"Toby Mathews" <to***************@yahoo.spamfree.co.uk> wrote in message
news:cf**********@thorium.cix.co.uk...
Can you make the code in your codebehind only execute the first time it
executes? i.e.

if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
After postback, the value of ImageUrl is coming from the control's

ViewState.

One solution would be to set the value of a hidden field when you set

the image's src attribute. The value of the hidden field will get posted back correctly.

"Guadala Harry" wrote:

> In an aspx page I have declared an Image control:
> <asp:Image id="myImage" runat="server"></asp:Image>
>
> In the code-behind I populate it's ImageURL property, like this:
> myImage.ImageUrl = "some.gif";
>
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("myImage").src = "other.gif";
>
> Here's the problem: on postback, the image control's .ImageUrl property > still contains "some.gif" and not "other.gif" as I am needing.
>
> What do I need to do to receive - during postback - the value set in the > client by the JavaScript?
>
> Thanks!
>
>
>
>



Nov 18 '05 #5
Harry,

Sorry, I didn't read your message properly first time round. I'm not sure
how else you could achieve what you want to do other than how you decribe.
Good luck,

Toby

"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).

Thanks anyway.
"Toby Mathews" <to***************@yahoo.spamfree.co.uk> wrote in message
news:cf**********@thorium.cix.co.uk...
Can you make the code in your codebehind only execute the first time it
executes? i.e.

if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks - I thought about going the hidden field route - but was hoping for some solution that wouldn't require adding another field or control that needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
> After postback, the value of ImageUrl is coming from the control's
ViewState.
>
> One solution would be to set the value of a hidden field when you set
the
> image's src attribute. The value of the hidden field will get
posted back
> correctly.
>
> "Guadala Harry" wrote:
>
> > In an aspx page I have declared an Image control:
> > <asp:Image id="myImage" runat="server"></asp:Image>
> >
> > In the code-behind I populate it's ImageURL property, like this:
> > myImage.ImageUrl = "some.gif";
> >
> > Then, in client-side JavaScript, the user can cause the image to
be > > replaced, like this:
> > document.all("myImage").src = "other.gif";
> >
> > Here's the problem: on postback, the image control's .ImageUrl

property
> > still contains "some.gif" and not "other.gif" as I am needing.
> >
> > What do I need to do to receive - during postback - the value set

in the
> > client by the JavaScript?
> >
> > Thanks!
> >
> >
> >
> >



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Richard | last post: by
2 posts views Thread by uNConVeNtiOnAL | last post: by
3 posts views Thread by Christopher Jeris | last post: by
7 posts views Thread by Jon Glazer | last post: by
2 posts views Thread by TuftyTrue | last post: by
1 post views Thread by Prisoner at War | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.