471,337 Members | 1,133 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Dynamically Changing an Image

I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute( "src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute( "src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
Nov 19 '05 #1
5 1821
following javascript would change an image to diffrent one

document["imgStatus"].src = "images/CR_On.jpg";

the VB Script syntax would be following ?.. I am not very familair with
VB Script

document("imgStatus").src = "images/CR_On.jpg"

Nov 19 '05 #2
Jerry,

Sure you can set the src on the client. The image control will get another image and render it, no problem.

Eliyahu

"Jerry Camel" <rl*****@msn.com> wrote in message news:Og**************@TK2MSFTNGP14.phx.gbl...
I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute( "src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute( "src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
Nov 19 '05 #3
I never would have figured you for an HTML
green background color user, Eliyahu.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ej***************@TK2MSFTNGP09.phx.gbl...
Jerry,

Sure you can set the src on the client. The image control will get another image and
render it, no problem.

Eliyahu

"Jerry Camel" <rl*****@msn.com> wrote in message
news:Og**************@TK2MSFTNGP14.phx.gbl...
I am interacting with an OCX on the client side. In the Onload event of the page, I am
checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a
different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with
VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute( "src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute( "src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm
already at the client. So how do I have the images "cached" so that I can change the src
dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry

Nov 19 '05 #4
Well, gone are those days when you could tell a real programmers by his
non-stop typing into a black MSDOS screen. Now you have to look into his
html background...:)

Eliyahu

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
I never would have figured you for an HTML
green background color user, Eliyahu.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ej***************@TK2MSFTNGP09.phx.gbl...
Jerry,

Sure you can set the src on the client. The image control will get another image and render it, no problem.

Eliyahu

"Jerry Camel" <rl*****@msn.com> wrote in message
news:Og**************@TK2MSFTNGP14.phx.gbl...
I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active." Document.getElementById("imgStatus").setAttribute( "src", "images/CR_On.jpg") Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active." Document.getElementById("imgStatus").setAttribute( "src","images/CR_Off.jpg") End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry

Nov 19 '05 #5
After all, the problem wasn't my code... Just where I had it in the document. Thanks for the input.
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:ej***************@TK2MSFTNGP09.phx.gbl...
Jerry,

Sure you can set the src on the client. The image control will get another image and render it, no problem.

Eliyahu

"Jerry Camel" <rl*****@msn.com> wrote in message news:Og**************@TK2MSFTNGP14.phx.gbl...
I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed.

If the port is open, I want a certain image to appear. If the port is closed, a different image.
Sounds pretty straight forward.

Since this is dependent upon a property of a client side component, I can't do this with VB .net on the server, right?

So I was trying to use vbscript on the client like this:

If Form1.CardReader.PortOpen = True Then
Document.getElementById("lblPortStatus").innerText = "Card reader is active."
Document.getElementById("imgStatus").setAttribute( "src", "images/CR_On.jpg")
Else
Document.getElementById("lblPortStatus").innerText = "Card reader is NOT active."
Document.getElementById("imgStatus").setAttribute( "src","images/CR_Off.jpg")
End If

What I've kinda figured out is that I can't really just change the src text 'cause I'm already at the client. So how do I have the images "cached" so that I can change the src dynamically? Or am I completely misunderstanding the problem?

Any help is appreciated. Thanks.

Jerry
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by C A Upsdell | last post: by
3 posts views Thread by SGA Smele | last post: by
4 posts views Thread by Chris Mahoney | last post: by
reply views Thread by =?Utf-8?B?SlA=?= | last post: by
7 posts views Thread by petethebloke | last post: by
reply views Thread by rosydwin | last post: by

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.