Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Changing image on an ImageButton makes by button disappear

Reply
Thread Tools

Changing image on an ImageButton makes by button disappear

 
 
abarberis@gmail.com
Guest
Posts: n/a
 
      01-11-2005
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

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      01-11-2005
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)


<> wrote in message
news: 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
|


 
Reply With Quote
 
 
 
 
Alex
Guest
Posts: n/a
 
      01-11-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid Paging makes DataGrid Disappear smithb1028 ASP .Net 7 01-28-2007 08:59 PM
Editing any of gridviews on a page makes bound controls in datalist disappear. HP ASP .Net 0 11-30-2006 06:00 AM
Outlook Express Messages Disappear, Bookmarks in Internet Explorer Disappear rchrdcarlisle@NOTyahoo.com Computer Support 19 07-30-2006 09:41 PM
Changing image on an ImageButton makes by button disappear abarberis@gmail.com Javascript 0 01-11-2005 07:23 PM
Putting image in <div> makes menu disappear! Kyle James Matthews HTML 2 04-23-2004 08:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57