Linking text boxes to buttons.

J

Joel Barsotti

Is there anything builtin to ASP.net that allows you to tie a text box to a
button so when you press enter in the text box it emulates clicking a near
by button.

I've coded up some client side javascript that does this, but it fails when
their is a validator monitoring the text box (in firefox, but that's 10% of
my visitors).
 
S

Steven Cheng[MSFT]

Hi Joel,

Welcome to ASPNET newsgroup.
Regarding on the TextBox's on enter key press and button's submitting, so
far there is no such buildin setting to associate them. And the problem on
using some custom client scrpit together with validation controls on
textbox does exists, this is actually related to the client validation
script which is called in the form's onsubmit event that occur after our
clientside onkeydown scrpit but before the form to be submit .... So
far, I'm afraid it would be hard to avoid it if we just use the textbox's
clientside "onkeydown" event to perform certain button's clicking(when
client validation is turned on....).

If you do need to use some custom script when client validation turn on,
one possible approach is do not make the submit button cause validation by
default but use some clientscript to manually call the clientside
validation function. You can view the html source for the asp.net page (use
valiation control and turn on clientside validation) in browser and find
the validation script's linked resource file like:

<script
src="/StevenRoot/Whidbey/WebSites/Test/WebResource.axd?d=nyC9UwOMc5RFmmFNmpq
nDtiUIx-5Dflmy7nzRpCO8Wg1&amp;t=632665397732419488"
type="text/javascript"></script>


After download it and open in text editor, we can view all the underlying
validation script functions which we can manuall invoke through our own
script code....

And the above is for asp.net 2.0's case, while for asp.net 1.1, you can
refer to the following msdn article on the validation's underlying details:

#ASP.NET Validation in Depth
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp?frame=t
rue

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Joel Barsotti" <[email protected]>
| Subject: Linking text boxes to buttons.
| Date: Mon, 23 Jan 2006 14:50:53 -0800
| Lines: 9
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: static-70-104-252-225.ptldor.dsl-w.verizon.net
70.104.252.225
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:372994
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Is there anything builtin to ASP.net that allows you to tie a text box to
a
| button so when you press enter in the text box it emulates clicking a
near
| by button.
|
| I've coded up some client side javascript that does this, but it fails
when
| their is a validator monitoring the text box (in firefox, but that's 10%
of
| my visitors).
|
|
|
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top