473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Client Side Events That Overlap

Gaz
This is impossible right??

This is a very simplified description of my form so don't worry if it
sounds like I could do it a different way, it's just because I have
simplified it. I have two controls. In control 1 you can update a text
value, the onblur event of this control will submit the form and
update the value on the server. When the onclick event of control 2 is
fired the form is submitted and on return the value in control 1 is
populated ready for editting.

You might be able to see the problem. If the onblur of control 1 is
fired because the user is clicking on control 2 then the event
handling code wants to submit the form twice. What happens is that the
onblur event of control 1 is lost because the onclick event of control
2 overtakes it. So if you make a change to control 1 and expect it to
be updated when the focus is lost when you click on control 2 then
you're in for a surprise.

I think that this is a pretty standard problem in a client-server
application like this. Only one event that goes back to the server can
run at a time. Any solutions to get around this are messy and
unintuitive when looking back at the code.

To resolve this issue I simply check in the onclick event of control 2
if a flag has been set by the onblur event of control 1. If it has
then then I show a warning to the user that they will have to click
again (not in an alert() box, which makes matters worse!), and I don't
submit the form because the onblur submit() is running.

Part of the problem is that when you submit a form the client
environment still seems to be running for a sub-second, so events can
get called when they aren't wanted.

I suppose the point of this message is, has anybody else faced this
problem and did they hit a brick wall like I have?

Thanks.
Jul 23 '05 #1
4 1517
In article <76*************************@posting.google.com> ,
oo******@yahoo.co.uk enlightened us with...
This is impossible right??

Maybe, maybe not. Depends.
This is a very simplified description of my form so don't worry if it
sounds like I could do it a different way, it's just because I have
simplified it. I have two controls. In control 1 you can update a text
value, the onblur event of this control will submit the form and
update the value on the server. When the onclick event of control 2 is
fired the form is submitted and on return the value in control 1 is
populated ready for editting.


This sounds like the following.
I edit a field.
I click on another field.
The onBlur of F1 fires.
The onClick of F2 fires.

If this is the case...

How this is done is slightly different from IE/Netscape. Is this an
intranet application? Does everyone use IE, or do you need the Netscape
code?

This simple test (see code below) shows that IE6 and Opera fire the blur
and never even fire the click. Put a value in the first field, then
click on the second. The alert for blur goes off, but not the click
alert.
Netscape 7 fired the click first, then the onBlur.

So, tell me more about what browsers you need to do this for.

--- test code ---

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function f_onBlur()
{
alert("blur fired");
}
function f_onClick()
{
alert("click fired");
}

</script>
</head>

<body>
<form name="frm1">
<input type="text" name="t1" onBlur="f_onBlur();"> <br>
<input type="text" name="t2" onClick="f_onClick();"> <br>
</form>
</body>
</html>

--
--
~kaeli~
I can't sleep.
The clowns might eat me.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Gaz
> I had to change the code to the following (provide IDs and post to self
instead of default.asp) for it to work. When it did, the event fired was
always onBlur(). It did let me type while it was processing, but when
the new page was returned, the event fired was onBlur(). Are you sure
this isn't a problem with your server or browser? I'm using ASP, not
ASP.net, and IE6.


Your version gave me the same result as my version - I don't
understand why my version didn't work for you as the changes you made
shouldn't make much difference I don't think. What version of iis are
you using? I am using 5.1 with Windows XP. Perhaps you have a faster
cpu so that the for-loop completes quickly enough so that the client
doesn't have time to.

I always get the last event as onClick when I click on control2.
Jul 23 '05 #3
In article <76**************************@posting.google.com >,
oo******@yahoo.co.uk enlightened us with...

Your version gave me the same result as my version - I don't
understand why my version didn't work for you as the changes you made
shouldn't make much difference I don't think. What version of iis are
you using?
Honestly, I don't know. It's not my server and I don't have access to
the administrator. I do know it's running on a real windows server set
up for high-end applications, so it's a fast, secure machine. I'm also
on a T3 backbone, so that's fast, too. It's an intranet.
I am using 5.1 with Windows XP. Perhaps you have a faster
cpu so that the for-loop completes quickly enough so that the client
doesn't have time to.


Well, that could be.
Let me increase it.
....

Nope, I upped it huge (for n = 0 to 5000000) and no difference. I kept
clicking and clicking, but still got onBlur.

This sounds like a bug somewhere. What version of IE are you using? IE5
had some bugs. I'm using IE6.
For giggles, get a computer with IE6 on it and test this page out (put
the page on a server where everyone can get to it), see what happens.

--
--
~kaeli~
Jesus saves, Allah protects, and Cthulhu thinks you'd make
a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
Lee
Gaz said:

the onblur event of this control will submit the form


Revisit that decision. In addition to the problem
that you're having, there are too many things that
are beyond your control, and the control of the user,
that can cause a field to lose focus.

The onBlur event handler should generally only
be used for tasks that are simple enough to be
independent of whatever triggered them.

Jul 23 '05 #5

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

Similar topics

1
by: Karl | last post by:
Hi I am new to asp.net and I need to get my head around the way client side events interact with server side events. I want to have three listbox's on a page, the value the user selects in the...
1
by: Matthew Louden | last post by:
Personally, I am totally confused with the following control terms and usage and advantages of each one in ASP.NET web application. Here's what I know so far.. 1. HTML Client Control: understood...
2
by: Rick Strahl [MVP] | last post by:
Run into an interesting problem today with a client of mine: They have an ASP.Net form that they want to drive through a client side HTTP interface. I know a Web Service would be a better way to...
5
by: Mong | last post by:
Hi, I have a webform with various asp controls on it such as textboxes and dropdownlists. I'm fairly new to asp.net coming from VB6 and am wondering when it's best to use client side events and...
2
by: Rea Peleg | last post by:
Hi all Is it possible to handle web controls events on client side??? I wrote a simple favascript function inside the <header> area of an aspx web form. This function is called on...
1
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that...
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
2
by: Stuart Whiteford | last post by:
Hi, I asked this back in January without answer and forgot about it until now. I've got a basic web form, two textboxes, a couple of radio button groups, some required field validators, and a...
7
controlbox
by: controlbox | last post by:
I have recently inplemented some drop-down lists (combos) on a page where one is dynamically populated according to the selection of another using the microsoft ajax extensions. I had to set...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.