double posting problem

  • Thread starter Boban Dragojlovic
  • Start date
B

Boban Dragojlovic

I have a webform that shows a long list of customers (500 - 1000) to the
user.



At the top of the form are various filtering options, including a quick
search input box.



If you set any filters, you need to click on the 'Filter' button to apply
the filter. In that case the form posts back to the server and performs the
filter.



But the quick search is designed to work easier/faster. If you type
anything into that box, and press tab, it posts back to the server
immediately and performs a search based on the text you entered.



I achieve this by coding these attributes into the quick search textbox:

AutoPostBack="True" OnTextChanged="QuickSearch"





Everything works fine if the user types something and presses Tab.



But, if the user types something into the quick search textbox, and presses
ENTER instead of TAB, then the form posts TWICE instead of once, and I wind
up duplicating data on the screen.





Currently the @Page directive has AutoEventWireup="false"



If I changed that to TRUE, it's even worse (it ALWAYS double posts).





Any ideas?
 
K

Kevin Spencer

You'll have to write a JavaScript routine that captures the ENTER key and
reacts appropriately.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
B

Boban Dragojlovic

Can you explain to me what is happening...

What do the two post events represent?
 
K

Kevin Spencer

The ENTER key in most browsers will submit a form by default. Your textbox
has an event handler that is triggered when the textbox loses focus. When
the form is submitted, the textbox loses focus, thereby triggereing 2
"events".

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
R

Rimu Atkinson

But the quick search is designed to work easier/faster. If you type
anything into that box, and press tab, it posts back to the server
immediately and performs a search based on the text you entered.
that's madness. that's not what the users will be expecting to happen, it
will confuse them. don't do it.
 
G

Gibs

you have to catch the enter key. you can use this piece in the
onsubmit="return false;" form tag.
 
K

Kevin Spencer

If they add that to the form, it will never submit.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top