473,320 Members | 2,052 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,320 software developers and data experts.

Changing image on an ImageButton makes by button disappear

I am writing an asp.net application which is using image buttons for
the interface. I have some buttons that have a enabled and disabled
state. I have written javascript code to change the image on the button
when it is disabled. Below is a snippet:

document.all.btnSignIn.src="Images/sign_in_disabled.gif";

This code correctly changes the image on the button. The problem is
that sometimes if you push the button, it will turn white almost as if
it is waiting to download the image. The page moves too quickly for it
to ever show the disabled version. However, you still see the button
"disappear" for a second before the new page loads.

I have tried to place a hidden version of the disabled image on the
site thinking it might force a download and cache it locally.

Anyone have an idea on how I can make the image switch instantly?
Thanks

Alex

Nov 19 '05 #1
2 1821
you are correct, its downloading the image. to cache it, in javascript
create a Image object.

<script>
var disabledImage = new Image()
disabledImage.src = "Images/sign_in_disabled.gif";
</script>

later:

document.getElementById("btnSignIn").src = disabledImage.src;

-- bruce (sqlwork.com)
<ab*******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
| I am writing an asp.net application which is using image buttons for
| the interface. I have some buttons that have a enabled and disabled
| state. I have written javascript code to change the image on the button
| when it is disabled. Below is a snippet:
|
| document.all.btnSignIn.src="Images/sign_in_disabled.gif";
|
| This code correctly changes the image on the button. The problem is
| that sometimes if you push the button, it will turn white almost as if
| it is waiting to download the image. The page moves too quickly for it
| to ever show the disabled version. However, you still see the button
| "disappear" for a second before the new page loads.
|
| I have tried to place a hidden version of the disabled image on the
| site thinking it might force a download and cache it locally.
|
| Anyone have an idea on how I can make the image switch instantly?
| Thanks
|
| Alex
|
Nov 19 '05 #2
Bruce,

I tried your suggestion but I am experiencing the same behavior. As far
as I can tell setting the disabledImage.src =
"Images/sign_in_disabled.gif"; stores a URL in the variable. I think
this is the same as setting the ImageButton.src...
Any ideas?

Thanks

Alex

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nicolas Keller | last post by:
Hi! I'm used to have Mozilla for testing my PHP sites when I'm coding. The site's nearly finished, now I've made a test with the Internet Exlporer... guess what... failed. The problem: I'm...
4
by: Ester | last post by:
I have an interior design of a living room with lights and aircond image. My task is to load the living room image without any light and aircond images as background image of a WebForm after that I...
2
by: Ester | last post by:
Instead of drag and drop image button from Toolbox and name the image button id on the properties box, I would like to load image button ID from database. I created a database table that stores...
3
by: David | last post by:
Hi, I am very new in the asp.net realm so this may be a very simple question for most of you. I want to put a little image icon in every button on my web form but there is no attribute in...
2
by: David Hearn | last post by:
I have an ImageButton control that I am using on one of my pages. Sometimes, this button will act as a button and redirect users to another page. But sometimes, it will just act as an image...
4
by: rkbnair | last post by:
Is there any way to display an image button instead of the traditional Edit/Update/Cancel push button in a datagrid (with bound data)?
5
by: Varangian | last post by:
Hi there experts, Is there a way to convert a System.Drawing.Image to an ImageButton. Maybe using ChangeType I don't know! Thank you
10
by: Edwin Knoppert | last post by:
I have an asp.net imagebutton with a clickevent. I have enclosed an anchor around the image and a small text. If i click the image the event is executed (while the href of the anchor shows in the...
2
by: smokeyd | last post by:
i am trying to create a simple image button rollover.. i have searched this forum and found a number of solutions but none seem to work. i am just trying to get the onmouseover to swap the image...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.