473,320 Members | 2,004 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,320 software developers and data experts.

GRRR! Pages submitting with Enter key, combined with .ASCX pages - help!

Totally hacked off here. I've written a user control that contains a
text box, a required field validator and a button (these being the
cornerstone of a search facility), all as ASP.Net server controls. The
user clicks the button, and server-side code does a redirect to a
search page, appending the search expression to the URL.

Great, I thought, let's move on. I then wrote an mailing list page
which included the aforementioned user control, then another textbox,
required field validator and button.

So, I load up the page, click the "Submit Email Addy" button - and the
search button required field validator kicks in. After research (on
Google Groups, natch), I figure out that it forms part of the page.
So, I disable the required field validator and it's viewstateenabled
properties. Then, when the user clicks the button, I re-enable the req
field validator, call Page.Validate(), and continue if things are ok.

This, when applied to my buttons and text boxes appeared to work - but
only if the buttons are clicked!!! If someone hits enter whilst in the
text box, the page submits, which is not desired. I've written a page
that, er, pages data with next/prev buttons. These buttons have their
viewstate disabled so I can enable them each time the page loads. So,
when the user hits enter in the text box, the whole page submits (the
validator code doesn't get fired) and the prev\next buttons are
disabled because that's their initial setting.

After yet more research, I found some javascript code that disables
the enter key in a text box, which works great... EXCEPT NOW, IF YOU
HIT ENTER JUST WITH FOCUS ON THE BROWSER, IT STILL SUBMITS!!! And the
search required field validator kicks in, which it most definitely
shouldn't (unless it's being picked up as the first "submit" button in
the page, yeah, that'd be it).

So, as just alluded to, I did more research and found out about
ASP.Net rendering ASP:button down to an <input type="submit"> control
and that reacts to a Enter keystroke because it's on a form.

In a nutshell: how do I a) stop the page from submitting JUST BY THE
USER HITTING ENTER and b) have separate textboxes, req. field
validators and buttons that act independently of each other?

Oh yeah: All by server-side stuff, no Javascript...

Thanks,

Mike Kingscott
Nov 18 '05 #1
0 1216

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

Similar topics

3
by: Mr. B | last post by:
GRRRR... I've run across a situation in which I have NO solution. Hopefully there is one. VB.net. It's rather simple. I've a ComboBox that get's populated via a Database. And I pre-select...
30
by: SpreadTooThin | last post by:
Damn.. FILE *fp was just sooo much easier than C++ file i/o... I just don't get it.. really! filebuf, istream, ostream, ifstream, ofstream, iosteam... what the f&(){( do I use to do binary file...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.