way to set background image static and it doesnt load after each postback?

  • Thread starter Thread starter Bogosian
  • Start date Start date
B

Bogosian

Hi to all.I have to solve the following problem.I have to make a
website which will be a web cache machine with the look of a real
cache machine - screen and buttons below it.So i plan the background
to be an image and when users cklick the buttons only some of the data
on the screen will change.I want to make this background image
static(including the buttons if possible because otherwise it'll be
very ugly if the buttons leave blank spaces after postback).I mean
that it shouldn be loaded after each postback(no matter whether from
the cache or downloaded from the server).What i really need is just a
small portion of information to be loaded after each postback
event.What would you advice me to do - IFrames + client scripts or
something else?
Thanks in advance.
 
It depends on how much your content is going to change. If you are going to
be loading entire pages, then the easiest way is to use IFrames. If you
aren't changing much, then you might consider using client-side scripts to
fetch the content from a web service and then inject into the InnerHtml of
whatever section you want to populate. Caution here, however, as this is a
very brittle approach: if scripts are disabled your application will break,
and if you are doing XML manipulation on the client you will find
differences in support among the various browsers.
 
Thanks for paying attention Chris.The idea with the InnerHtml sounds
good because there are just 5 fields on the page which will change
when the user interacts with the cache machine.Could you tell me more
about this idea.More specifically is there a way to get all the data
in only one request to the server and separate it on the client
machine because all the information for the five fields is related and
can be calculated in one and the same portion of code and returned in
one response.Can you recall any places on the Internet where i can
read more about client-side scripts(i've only dealt with jscript a
little) and interacting with web seervices?
 
I forgot to mention that i want some of these fields to contain jpeg
images - so is there a way the web service return 3-4 images to the
script which are afterwards displayed on the page?
 
For fetching 5 text fields, that's easy to do in one hit. You can grab a
single XML document that holds all five fields as five XML elements. You can
parse this on the client using the XML handling capabilities of the
platform. Here it gets a bit tricky, because I only know of ways to support
this in IE 4.01+ and Netscape 6.0+, so if you have to support Netscape 4 or
IE 3, you will have problems. Just create an object of type DOMDocument (I
typically iterate through MSXML2.DOMDocument.4.0, MSXML2.DOMDocument.3.0,
MSXML2.DOMDocument, MSXML.DOMDocument, and Microsoft.XmlDom until I get a
successful object creation) for IE. For Netscape/Mozilla, it is
document.implementation.createDocument(...). You can do this asynchronously
by setting the onreadystatechange (IE) or onload (Netscape) property of this
object, and then in your async return handler just use XML functions to get
that data (for example, getElementsByTagName) and then pump it into the
innerHTML property.

As for places to learn, I picked up most of my JavaScript from SDK docs and
one of the O'Reilly books (whose name I can't recall, as it's on my
bookshelf at home) so others probably have better recommendations in this
regard.

Finally, regarding images, you can always set up an aspx site whose return
type is the image type that you want, and then pass back images dynamically
based on whatever criteria you are using to select them. Alternately, you
can store the direct link to the images, and then hit them. If you want a
single traversal, you may want to just have an HTML page containing all 5
fields (in tags with a unique ID) and the images you need, which you can
then fetch using XMLHTTP and then parse using the DHTML DOM.
 
Chris,thank you very much for bothering to advice me.I have two final
questions.
It's about the background image of the page - as i said the page is a
web cache machine and my idea is the background to look like a cache
machine.So i've read somewhere that by deafault the content of a web
directory doesnt expire unless you set it to in IIS.So if I place the
background image in a separate directory on the server wont this solve
the whole problem - I mean wouldnt it look static on the client's
browser when he or she presses a postback button without getting a
blank screen for parts of the second?The other thing is that for the
purposes of the application i need the user to be in a session because
the interactions with the machine cant be standalone but one after
another and using session information to calculate the consecutive
responses.So I cant use webservices to make the requests because i
wouldnt be able to use what sessions give to me.I am asking whether i
can fetch information using some different approach - for example
after pressing the button which should do the postback stuff to run
some client-side script which to address an aspx page which will
return information(like the appropriate query string to attach to the
src property of an img element which will get the right jpeg).These
are my thoughts can you add something.Thanks once again.
 
Back
Top