473,763 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preload Images in Asp.Net 2.0. How can I do this?

Hello,

I am working in Asp.Net 2.0 web sites and I need to preload some images
in my master pages and in the pages that use those master pages.

Could someone tell me how to do this?

Thanks,

Miguel

Nov 25 '06 #1
4 10364
"shapper" <md*****@gmail. comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
I am working in Asp.Net 2.0 web sites and I need to preload some images
in my master pages and in the pages that use those master pages.

Could someone tell me how to do this?
I'm not sure what you mean by "preload some images"...

Maybe you're slightly confused about what MasterPages are or, more
importantly, what they're not - they're certainly not some sort of new
version of a frameset. The content pages aren't like iframes or anything
like that. MasterPages are, in fact, not pages at all - they are
UserControls which allow content pages to share the same look and feel etc.
However, each time a content page is requested, it ASP.NET builds the entire
page from the beginning, surrounding the content page with the MasterPage's
markup. There is nothing "preloaded" , as such...
Nov 25 '06 #2
Hi,

Maybe I am explaining it wrong.
I am creating a custom control which given a list of images generates
the javascript code and add it to a page so the images are preloaded.

I want to use it in my master pages or in my pages.

Now i am looking for the right javascript code. Any ideas?

I also need to check if I can use it in a Master Page.
I know that I need to add the javascript code to the page. That's ok.
The problem is that I also need to add some code to the Html body tag.

Something like <body onload="...">

Any idea of how to do this?

Thanks,
Miguel
Mark Rae wrote:
"shapper" <md*****@gmail. comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.com.. .
I am working in Asp.Net 2.0 web sites and I need to preload some images
in my master pages and in the pages that use those master pages.

Could someone tell me how to do this?

I'm not sure what you mean by "preload some images"...

Maybe you're slightly confused about what MasterPages are or, more
importantly, what they're not - they're certainly not some sort of new
version of a frameset. The content pages aren't like iframes or anything
like that. MasterPages are, in fact, not pages at all - they are
UserControls which allow content pages to share the same look and feel etc.
However, each time a content page is requested, it ASP.NET builds the entire
page from the beginning, surrounding the content page with the MasterPage's
markup. There is nothing "preloaded" , as such...
Nov 25 '06 #3
"shapper" <md*****@gmail. comwrote in message
news:11******** **************@ l39g2000cwd.goo glegroups.com.. .
Maybe I am explaining it wrong.
I am creating a custom control which given a list of images generates
the javascript code and add it to a page so the images are preloaded.
Hmm - still don't know what you mean by "preloaded" - a page is loaded when
it's requested, unlike e.g. a WinForm which *can* be preloaded and then made
visible at a later date...
Now i am looking for the right javascript code. Any ideas?
Not till you actually explain what you're trying to do...
The problem is that I also need to add some code to the Html body tag.

Something like <body onload="...">

Any idea of how to do this?
<body id="MyBodyTag" runat="server">

MyBodyTag.Attri butes.Add(".... .", ".....");
Nov 25 '06 #4
Hi,

shapper wrote:
Hi,

Maybe I am explaining it wrong.
I am creating a custom control which given a list of images generates
the javascript code and add it to a page so the images are preloaded.

I want to use it in my master pages or in my pages.

Now i am looking for the right javascript code. Any ideas?

I also need to check if I can use it in a Master Page.
I know that I need to add the javascript code to the page. That's ok.
The problem is that I also need to add some code to the Html body tag.

Something like <body onload="...">

Any idea of how to do this?

Thanks,
Miguel
Here are a few hints to get you started.

You preload images in JavaScript using the Image object. You use the
onload event to check when an image is correctly fully loaded. You use
the onerror object to check when an error occurs (for example when an
image is not found.

The onload and onerror event handlers cannot take parameters. Either you
don't need them (for example, you decide that if one error occurs, then
the whole page is invalid), or you can use closure to pass parameters to
the handling function anyway.

Example:

var myImage = new Image();
myImage.onload = imageOnLoad;
myImage.onerror = imageOnError;
myImage.src = "myimage.gi f"; // This is the line starting the request

with:

function imageOnLoad()
{
writeStatus( "One image loaded, only " + iImages-- + " to go..." );
}

function imageOnError()
{
alert( "Big problem" );
}

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 25 '06 #5

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

Similar topics

2
1657
by: DiggidyMack69 | last post by:
Hello folks I have a rolling image script that works fine except that the images do not seem to be preloading properly. The images are still being pulled on every interval from the server according to the logs...is it because I am using the document.write method? Is that forcing a refresh? <SCRIPT language="JavaScript" type="text/javascript"> // BEGIN rolling images code
5
3520
by: hoolie | last post by:
I'm preloading images with the standard code: default1 = new Image(); default1.src = "images/image1.gif"; changed1 = new Image(); changed1.src = "images/image1-on.gif"; default2 = new Image(); default2.src = "images/image2.gif"; changed2 = new Image(); changed2.src = "images/image2-on.gif"; And this is my rollover code: var iName="";
1
1151
by: ks | last post by:
HI is it possible to preload images to client browser directly from sql server without storing them on server space Have a nice day thanks in advance ks.
4
1735
by: shapper | last post by:
Hello, I think to preload an image I should us something like: img = new Image(); img.src = 'images/img.jpg'; Could someone tell me how to create a loop which would preload a list of images? Something like:
2
1516
by: =?Utf-8?B?Q2FzcGE=?= | last post by:
Is there any way to preload an image returned by an HTTP Handler? My image HTTP handler is generating some thumbnails that I want to preload. thanks Caspa
3
1725
by: blobb | last post by:
hi all, i have 50 hidden div layers with images insided, each is appr. 200kb big. i use this script to show/hide them, when neccesary: function init() { IE = (document.all) NC = (document.layers) Opera = (document.getElementById)
9
1969
by: shapper | last post by:
Hello, How can I preload a few images of a page javascript? Should I use CSS to do this? Is it even possible? Thanks, Miguel
2
1375
by: CK | last post by:
Words to the wise, Henry <rcornford@raindrop.co.ukwrote: Sorry for the delay, was overly swamped and only managed to be able to free some time last week to work on this. Yes, that was the whole problem. Adding Cache-Control with max-age solved the problem. I tried to add a FileETag as well, but this does not seem to make any
3
1890
by: Revathi Balakrishnan | last post by:
Hi i have the used the below code to switch the button image on mouseover and mouseout. <html:button property="Button" value="Display" styleClass="displaybutton" onmouseover="this.className='displaybutton displaybuttonover'" onmouseout="this.className= 'displaybutton'"/> CSS definition of displaybutton and displaybuttonover is shown below.
0
9386
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
9998
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
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
8822
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
7366
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
6642
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
5270
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...
3
3523
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.