473,811 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1553
In article <76************ *************@p osting.google.c om>,
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_onBlu r();"> <br>
<input type="text" name="t2" onClick="f_onCl ick();"> <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
1300
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 first listbox determines the second listbox's values, the value the user selects in the second box determines the third listbox's values etc. I double clicked on the first listbox to generate a code
1
2535
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 by the client only. e.g. <input type="text" name="emp_name"> 2. HTML Server Control: understood by the server only. e.g. <input type="text" name="emp_name" runat="server"> 3. Web Server Control: understood by the server only. e.g. <asp:TextBox
2
2174
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 go but in this case they want to try and consolidate a single interface for the 3 or 4 forms involved and drive them through a WebRequest Http client. The data is getting there no problem - it's retrievable with Request.Form. However ASP.net is...
5
2607
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 when it's best to use server side events. For example, if a textbox is to contain a date I want to validate the date when that textbox loses the focus. If the date is not valid I make visible a label next to the textbox telling the user it's
2
1950
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 selectedIndexChanged event of server side radio button list, but i can not get there . During compilation, it seems like the dotnet asp service is looking for this function on that web form's (server side) code
1
5243
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 appear to be the result of double-clicking the submit button on the form. The form has three ASP:Button tags, each of which gets translated into INPUT TYPE="SUBMIT" HTML elements. One submits the form's data. One logs the user out. And the other...
10
2059
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 whole day is then displayed in cels of a table. The user has then to click in a cel representing a hour of the day and an object (book ..), and finally click on the submit button to insert that reservation in the database. My problem is: there...
2
2664
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 Submit and Cancel button. When the page loads, if I click the Cancel button, the server-side event fires as normal.
7
22500
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 AutoPostBack = true, and enable viewstate in order for the serverside events to fire, but once this was done, all seemed well - so far so good... Also, when the page form is submitted, the Javascript validateForm() function is executed to perform...
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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
10395
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
10408
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
9211
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...
0
6895
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();...
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.