473,769 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ImageUr l = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("m yImage").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 2245
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.ImageUr l = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("m yImage").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*******@disc ussions.microso ft.com> wrote in message
news:E0******** *************** ***********@mic rosoft.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.ImageUr l = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("m yImage").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.IsPostba ck)
myImage.ImageUr l = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.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*******@disc ussions.microso ft.com> wrote in message
news:E0******** *************** ***********@mic rosoft.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.ImageUr l = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("m yImage").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.spamf ree.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.IsPostba ck)
myImage.ImageUr l = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.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*******@disc ussions.microso ft.com> wrote in message
news:E0******** *************** ***********@mic rosoft.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.ImageUr l = "some.gif";
>
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("m yImage").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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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.spamf ree.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.IsPostba ck)
myImage.ImageUr l = "some.gif";

Toby Mathews

"Guadala Harry" <GM**@NoSpam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.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*******@disc ussions.microso ft.com> wrote in message
news:E0******** *************** ***********@mic rosoft.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.ImageUr l = "some.gif";
> >
> > Then, in client-side JavaScript, the user can cause the image to
be > > replaced, like this:
> > document.all("m yImage").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
2955
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="#" onMouseOver="document.main.src='image2.jpg'"
1
1606
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 brand new ones (Compaq 15K RPM 32GB drives). We are currently experiencing ASR almost on a daily basis and it is really causing a disription in service. SO, The Network Admin ahs made this decison to replace these drives in attempt to solve this....
2
1585
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 trying to do image swapping This snippet will prevent 'null' from appearing initially and successfully records user changes (typing in a comment)
3
2087
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 would also appreciate any general criticism you have to offer. I don't know yet how to write the degradation-path code for browsers that don't support the DOM methods I'm using, so there are some commented-out paths below. If the content...
7
1291
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 = x.src; x.src = y.src; y.src = pictemp; }
6
2267
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 only. http://www.casespace.net I designed it with firefox (plus the autohide extension) in mind, but also want to support IE. Online and offline it works great in Firefox. Offline it also works
2
2130
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 = URLtoPictureOnWebServer.src; I cant get it to work with:
1
1462
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
1051
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 replaced, after eight more seconds, with the original image. For some reason, JavaScript keeps swapping the images back and forth endlessly -- and not even properly counting out all the seconds specified, after the first time swapping! What's...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.