473,503 Members | 4,234 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 10349
"shapper" <md*****@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.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.googlegr oups.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.googlegr oups.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.Attributes.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.gif"; // 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
1644
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...
5
3504
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();...
1
1137
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
1704
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...
2
1505
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
1694
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 =...
9
1946
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
1355
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...
3
1874
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" ...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
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...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6975
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...
0
7449
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...
0
5562
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,...
1
4992
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...
0
4666
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...
1
728
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.