Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Preloading images for rollover buttons (C#)

Posted on 2006-11-12
6
Medium Priority
?
558 Views
Last Modified: 2012-06-27
Hi All!

I have a webpage with some rollover graphics that are quite large.  I would like them to preload as soon as the page does, rather than waiting for the user to put their mouse over them.  To be honest, I'm running it locally so it's hard to tell whether it's doing it or not - but my understanding is you need some javascript or similar to get them to preload, and it will be deployed to the web soon enough.

Can I do it in C# in the Page_Load section, or do I need Javascript?  Either way, what code would I use?

Many thanks everyone!
0
Comment
Question by:glinkot
  • 3
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
ryandale56 earned 1000 total points
ID: 17927821
0
 

Author Comment

by:glinkot
ID: 17927836
Hi Ryan,

Many thanks.  I did do some googling and saw similar type of stuff - is there always a necessity to specify the image size for these scripts?  Manually finding out the size of every image is kind of acceptable, but not the ideal for a long term effort.

Thanks
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 17927916
>> "is there always a necessity to specify the image size for these scripts"
I've never used them, just leave the prams empty ()


>> "I'm running it locally so it's hard to tell whether it's doing it or not "
Go to google, and search for a larger image, and use that just for development testing.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:glinkot
ID: 17928134
Aha!  Are there any requirements around naming the pic versus the servertag name-ie do they need to be the same name, or do they need to differ for some reason?  I assume it just caches via the filename and when the servertag sees that it needs that path and filename, it picks it up from the cache rather than the webserver.

Am I right do you think?

Many thanks
0
 
LVL 12

Assisted Solution

by:UnexplainedWays
UnexplainedWays earned 1000 total points
ID: 17928193
>> "Are there any requirements around naming the pic versus the servertag name-ie do they need to be the same name"

VARIABLE = new Image();
VARIABLE.src = "FILENAME";

the variable and filename can be anything, and the name/id of the <img> or <asp:Image> makes no difference.  The only reason it would matter is when you want to assign the new filename to the image, cause without the id/name you can't find it.


Also, you can keep the VARIABLE  global, so say you have

imgOn = new Image();
imgOff = new Image();

imgOn.src = 'on.gif';
imgOff.src = 'off.gif';

and then in your code, you change the src of the image alot (and in different places), you can keep the filename down to one place (above) and use that when assigning the new image, example:

document.getElementById("TheImageId").src = imgOn.src;


And about the cashing, as far as i know, if you do this:

imgOn = new Image();
imgOn.src = 'on.gif';
---then later---
document.getElementById("TheImageId").src = 'on.gif';

This will look in the temp inet files first for the image, if it's there walla, if not u know what it does.  So it's not really about what the javascript does, its about if the file matches the name.


0
 

Author Comment

by:glinkot
ID: 17928293
Thankyou so much for your help guys!  Really appreciate your efforts.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question