Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Causing timed form Post

  Asked By: Fern    Date: Aug 03    Category: Asp.net    Views: 6140

I'm trying to cause a form to resubmit after
a 3 second interval. When I click an ImageButton
I want to start a timer which then calls a function
which submits the form so that I can call a new function
from the Page_Load event. I tried to use a setTimeout
on the client-side but it fired before I wanted it to.

I haven't been using ASP.Net very long and am
still trying to find out what is possible. I want to
click the ImageButton and then replace the image
in it after 3 seconds.



6 Answers Found

Answer #1    Answered By: Umaiza Hashmi     Answered On: Aug 03

Well it depends what side you want the timer  on.
If you say that jscript didn't work then you try the meta tag "refresh".
If you want this timer to run from the server then you will have to restrict your users to Netscape browsers - as you would have to push the data to the browser.

pst ... have altered your dynamicimages to pull images from a resource dll, but as you said in a previous post, it's maybe best to keep httphandlers seperate in some cases. This is a perfect example. You don't really want to have to create a new httphandler for every image library you use ... so I'm altering it again to sepearte library from handler and then pass the library to the handler as a property.

I may change to a factory instead ... it depends on playtime ... computing might be too hard.

Answer #2    Answered By: Barachias Levi     Answered On: Aug 03

I'd like to see what you come up with.
I plan to refine it myself.

What I'm trying to do with the timer  is
write another Handler which will enable
me to click  on an ImageButton and pass
the X, Y coordinates and the size and
image path to the Handler. This Handler
will cut a rectangle out of a larger image
and pass it back so that I can show
increased detail.

After thinking about it I decided I would
be better off opening a new window
on the ImageButton click and accessing
the coordinates thru Session variables.
I would then pass this to the Handler from the
new window, receive the detail image back
and then close the new window with
setTimeout('window.close()', 3000). This
makes this easy and saves me 1 form

Answer #3    Answered By: Naomi Lee     Answered On: Aug 03

Use your DynamicImages ashx to gerate the images but modify it to take a width
and length.

Fine. So out image is client side.
You then have to generate an image map, this image map will get the x,y co-ords
of the mouse for you.

You pass them back to the server on the click  of your button, which then
modifies the image and sends it back : whether or not you wish to expand that
cropped image back to teh size of your original image is up to you.

You then have a cropped image in your window and not the original.

You could do it your way and crop the image into a new window, that window could
be sized the original image dimensions or to the cropped image dimensions -
depending on whether you wish to explode the cropped image into the original

Ironic ... a quite few years back I did just this but with not with IE windows
and C# server code but with J++ forms and AWT Frames.

Which brings me to the concept of doing it all client side.

I would think that you could.
You could do it all in javascript.
Give the image an id when its downloaded.
Grab and crop that image and open a new window to display the cropped version -
all done client side.
There is plenty of mouse code around that you can use to track the mouse and
thus get the image co-ordinates you require.
The dodgy bit is what you can do with the javascript image object ... whether or
not it will let you manipulate it's dimensions.

However the good bit about the language java ( and something .NET CANNOT do) is
that you can access the java VM directly from client side script, and so can
just about anything could possibly want to do with an image.

If you need any help with image map bit then let me know, I have it all
somewhere (my html book in a box, behind my new kitchen unist tht hasn't been
fitted yet - but I'll dig it out for you!)
I know that it CAN definately be done completely client side && possibly using
java, but I don't really want to spend time in java or in javascript.

The main thing being is that an image map will get the co-ords for you.

Answer #4    Answered By: Bathilda Schmidt     Answered On: Aug 03

I got this thing cooking the way I wanted  to,
but I have 1 small problem. I click  on the ImageButton
which opens a new window and reads the x, y coords
from Session vars then invokes the Handler to get me
the detail image. Great, works fine. Image returns and
loads in an Image control in the new window, 3 seconds
later the new window closes. Now, if I want to click the
ImageButton again, the window opens and I see the
image I saw last time. If I click the same spot a second
time I then get what I wanted. I wonder if the browser
is caching the image, because each time I ask for this
image it has the same file name.

I'm thinking about changing it so that when I click on
the ImageButton it goes and gets the new image and I save
the original image on the client-side. Then I'll show the new
image in the ImageButton and after 3 seconds replace  this
new image with the original by using a 3 second setTimeout
activated by a click event  attribute added to the ImageButton.

I don't think my Handler code could be duplicated with
Javascript. Check the attachment.

Answer #5    Answered By: Joyce Edwards     Answered On: Aug 03

Sounds to me like an event  firing thingy.

Image gets downloaded - fine.

Now if the browser is to opena new window with the detail image then it has to
post the co-ords back to the server.
But you have to make sure that the server updates the session vars BEFORE
creating the detail image to return to the client.

If your image control are within the same page and so forth this can be caused
by the event firing order. i.e. your image control tells the session vars to
update after the page has already sent the detail image back from it's
previously stored co-ords.

You could test that by initialising the session vars to something weird - like
the bottom right of the image.

Then, the first time you request a detail image (with proper co-ords) you might
find that you get that one from the bottom right.

Mark - I've been doing some work on this aswell, but client side stuff.

How are you deciding what part of the image to detail ? Are you using an image
map ? I'll post  my code to you when it's sorted out, basically it's javascript
that will grab 2 points from an image when you drag a diagonal across an image
... but there's a small hiccup at the moment - it works - but not well enough.

I have posted a question called javascript - an easy one - have read and see if
you know.

Also - there was no code attatched to this email. If you send it I will do my
best to sort it out. And combine it with my jscript and send it back to you !

Also I don't know why you are using session vars - all you need to do is
get the co-ords and send them in a querystring to have the control immediatley
grab the querystring and send back the image.

Answer #6    Answered By: Adel Fischer     Answered On: Aug 03

Your page downloads with the image.

You click  the button and it posts back and gets a new page, and that page opens
up a new window with the image.

Question :: how does that window get the image ? what is in that window ? how
did the html code in that new window get there ?

If you open that window with an url, then it has to go back to the server to get
the actual image - which is another trip.

What happens is this Mark, if you think about it. I we click any sort of button
that posts back to the server with the co-ords - then that delivers a web page
to the browser but NOT with the image - with the image url - that image url then
has to go back to the server again to actualy get the binary image data.
(it would be different if we could send the coords to the server and get the
image straight back .... but this would involve an embedded image (which you can
do in mht files but not htm files ... i.e. <img
So it's a bit different to collecting data.

Better is this.

Click the button, but one which doesn't post  back to the server but opens up a
new window, in that new window write code to fetch the image.

function OpenWin(){
var item = document.images.im;
var ww = yourwindowwidth
wh = yourwindowheight
var props =
props += ww;
props += ',height=';
props += wh;
props +=',left=270,top=270';

var bod = "<BODY>\n";
bod += blablahblahblah
bod += "<img src='" + dynamicimages.ashx??x1=p1&x2=p2&y1=p3&y2=p4 +
"' id='im'>\n";
bod += blablahblahblah
bod += "<\/BODY>\n";

So that the way I've domn eit except that there is no button, I have caputered
mouse events and when I drag across a specified image it grabs mouse down and
mouse up points and opens the new window with those points written into the code
- so then that window opens client side immediately and fetches the image from
within itslef.

You could do more or less the same thing with an iframe or even a div or a

Well thats how I looked at it anyway.

And yes, the browser will definately cache the image. But it defines between
different querystrings so if one image was fetched with one query string the
cache will store it sepeartely to one with the same file name but different
querystring - that quesrystring being the co-ords.

I think, but am not sure that, that you can get away from cached images if you
use this

<img src='' id='im>
var img = new Image();
img.src = "/server/dynamicimages.ashx??x1=p1&x2=p2&y1=p3&y2=p4";
document.images.im.src = img.src

I thing the img.src tag doesn't look in the cache .... but don't quote me.

So .... watch out MapPoint, you have competition.

Now all we have to do is get some huge database of every postal address and
every postal address system in the world, comprehensive global satellite images
of the surface of the planet taken at different altitudes, and again at night,
and in the winter,summer, autumn, spring, and climate data, stars, and ......

.... and then create our own binary format database running on it's own
optimized server that gives us super fast access to this vast amount of data so
we can generate the images we wish to display ... and all so your local
superstore can supply a map to give some business man directions to their store,
through a monitor installed in a highly noticable portion of his BMW's dash
board whilst telling him to turn left or right through his mobile phone .... and
with all this going on and he's expected to cope ? Bear in mind he thinks he's
James Dean and he's got 600 horses under his hoof and a crumple zone that would
frighten a Boeing, I give him and/or his immediate vicinity about a minite of
existence left.

Didn't find what you were looking for? Find more on Causing timed form Post Or get search suggestion and latest updates.