473,328 Members | 1,534 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,328 software developers and data experts.

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 2223
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard | last post by:
I'm beginning to undertake php for the fun of it. Working on a problem I hope can be solved in php. Basically what I have is this: <body> <img name="main" src="image1.jpg"> <a href="#"...
1
by: Travis L. Alltop | last post by:
All, To make a long story short, we are swapping out the "knock-off" drives that the NA purchased on E-Bay in one of our production SQL Servers (SQL Server 2000 Enterprise) this weekend for...
2
by: uNConVeNtiOnAL | last post by:
Hi - I have a page that has a button that makes a prompt appear for the user to type input. When they have typed in input, I want the button to change color when the prompt closes. I am...
3
by: Christopher Jeris | last post by:
Please help me understand the differences, in semantics, browser support and moral preferredness, between the following three methods of swapping content in and out of a page via JavaScript. I...
7
by: Jon Glazer | last post by:
I know this is sorta reposting but I want to simplify the issue a bit. Take the following script: function replacemain(s){ var x = document.images; var y = document.images; var pictemp =...
6
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution...
2
by: TuftyTrue | last post by:
Hi, On my site the user can browse to an image with <input type=file etc>. Althrough I have no problem swapping images with: document.getElementById('PictureToDisplay').src =...
1
by: skinymike | last post by:
i have a simple page code: pls see below <HTML> <BODY> <a onClick="document.images.src='click.gif'"> <IMG SRC="unclick.gif"></a> </FORM> </BODY> </HTML>
1
by: Prisoner at War | last post by:
Hi, Everybody, The fucntion below is called by an onLoad <imgattribute, and it is supposed to replace the original image, after three seconds, with another image. This second image shouldl be...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.