473,763 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make button "default"

Does anyone have some sample script to "press" a button or image button when
the user presses the Enter key? I see this behavior on a lot of web pages
but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net

Nov 17 '05 #1
6 8226
"Paul Turley" <pa**@createsol utions.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Does anyone have some sample script to "press" a button or image button when the user presses the Enter key? I see this behavior on a lot of web pages
but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net


Just use the HTML tag <input type="submit" value="click here or press
enter">

--

Jos Branders
Nov 17 '05 #2
Hi Paul,

In case you have multiple buttons on a webform, you could try this method.

When a webform contains multiple buttons, the first one rendered will be
fired when you press the Enter button. However, we can workaround this
problem using the
following method:

1. Add the following script code to the <head> section of the aspx page.

<SCRIPT LANGUAGE="javas cript">
function testEnterKey()
{
if (event.keyCode == 13)
{
event.cancelBub ble = true;
event.returnVal ue = false;
Form1.Button2.c lick();
}
}
</SCRIPT>

2. In the code-behind page, add the onkeypress event handler to the
attributes collectioins of the TextBox(es) on the page:

private void Page_Load(objec t sender, System.EventArg s e)
{
//other initialization code

TextBox1.Attrib utes.Add("onkey press", "testEnterKey() ;");
TextBox2.Attrib utes.Add("onkey press", "testEnterKey() ;");
......
}

More information:

HOWTO: Prevent Form Submission When User Presses the ENTER Key on a Form
(Q298498)
http://support.microsoft.com/support.../Q298/4/98.ASP

returnValue Property
http://msdn.microsoft.com/workshop/a...erties/returnv
alue_1.asp

cancelBubble Property
http://msdn.microsoft.com/workshop/a...erties/cancelb
ubble.asp

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Paul Turley" <pa**@createsol utions.net>
| Subject: Make button "default"
| Date: Wed, 25 Jun 2003 22:08:00 -0700
| Lines: 12
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <Od************ **@TK2MSFTNGP11 .phx.gbl>
| Newsgroups:
microsoft.publi c.dotnet.framew ork.aspnet.webc ontrols,microso ft.public.dotne t
.framework.aspn et
| NNTP-Posting-Host: ts46-03-qdr3731.porch.w a.charter.com 68.113.26.153
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1550 03
microsoft.publi c.dotnet.framew ork.aspnet.webc ontrols:12621
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Does anyone have some sample script to "press" a button or image button
when
| the user presses the Enter key? I see this behavior on a lot of web pages
| but I'm not finding any samples.
|
| Thx
|
| --
| Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
| pa**@createsolu tions.net
|
|
|
|

Nov 17 '05 #3
Set the "tab index" to 1
"Jos Branders" <jo************ ***@fastmail.fm > wrote in message
news:3e******** *************@r eader0.news.sky net.be...
"Paul Turley" <pa**@createsol utions.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Does anyone have some sample script to "press" a button or image button

when
the user presses the Enter key? I see this behavior on a lot of web pages but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net


Just use the HTML tag <input type="submit" value="click here or press
enter">

--

Jos Branders

Nov 17 '05 #4
I've tried this. I'm setting the tab index of my web server button to 1 and
I've set it to the next index in sequence for all the controls. In either
case, pressing Enter does nothing. This is on a web user control. I think
I need to use client-side script to capture the Enter key press - unless I'm
missing something.

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net
"Tim Boland" <bo*****@email. uc.edu> wrote in message
news:OK******** ******@TK2MSFTN GP10.phx.gbl...
Set the "tab index" to 1
"Jos Branders" <jo************ ***@fastmail.fm > wrote in message
news:3e******** *************@r eader0.news.sky net.be...
"Paul Turley" <pa**@createsol utions.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Does anyone have some sample script to "press" a button or image
button
when
the user presses the Enter key? I see this behavior on a lot of web

pages but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net


Just use the HTML tag <input type="submit" value="click here or press
enter">

--

Jos Branders


Nov 17 '05 #5
The web server button control renders these tags: <input type="submit"
name="Login_Con trol1:btnLogin" ...

I am calling server-side code on the click event so I need to use a web
server button or image button.

I've set the tab index to 0, 1 and other values. Any ideas?

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net
"Jos Branders" <jo************ ***@fastmail.fm > wrote in message
news:3e******** *************@r eader0.news.sky net.be...
"Paul Turley" <pa**@createsol utions.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Does anyone have some sample script to "press" a button or image button

when
the user presses the Enter key? I see this behavior on a lot of web pages but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net


Just use the HTML tag <input type="submit" value="click here or press
enter">

--

Jos Branders

Nov 17 '05 #6

I used this script for component asp:button but it didn't work. Than I
changed the component with asp:imagebutton (also added gif image for button)
and used this script. Now it works right.

<input type="text" onkeypress="if (event.keyCode == 13) return false"
runat="server">

lep pozdrav, Jure

"Paul Turley" <pa**@createsol utions.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
The web server button control renders these tags: <input type="submit"
name="Login_Con trol1:btnLogin" ...

I am calling server-side code on the click event so I need to use a web
server button or image button.

I've set the tab index to 0, 1 and other values. Any ideas?

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net
"Jos Branders" <jo************ ***@fastmail.fm > wrote in message
news:3e******** *************@r eader0.news.sky net.be...
"Paul Turley" <pa**@createsol utions.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Does anyone have some sample script to "press" a button or image
button
when
the user presses the Enter key? I see this behavior on a lot of web

pages but I'm not finding any samples.

Thx

--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
pa**@createsolu tions.net


Just use the HTML tag <input type="submit" value="click here or press
enter">

--

Jos Branders


Nov 17 '05 #7

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

Similar topics

2
3626
by: AA Arens | last post by:
When I place a record serch utility (vos the button placement wizzrd), I discovered that the Match setting is "Whole Field" by default. How to make "Any Part Of Field" default?
2
7978
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to close out the form, in which case I can look at the entire set of values and see if they're OK. So, I have this code. for the "Before Update" event: if (their variables are inappropriate) then msgbox "You've entered bad variables (or some...
3
5574
by: C# Learner | last post by:
Is it possible to set a command button to the "default" button of the form? Here's an example of what I mean -- press Start -> Run. Notice that the "OK" button has a dark rectangle around it, and when you press ENTER, this "OK" button's Click event handler is eventually fired. I was expecting Button to have a Default property, but can't seem to find anything like it...
5
3914
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are with the same solution. All had "Default" set in the "Struct Member Alignment" entry. After some assembler debugging we found out that a struct member that is a member function pointer in
8
3513
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I cannot load/unload/reload extensions into my large and slow-to-load application during development without restarting the process then the disadvantages may outweigh the advantages. I've got a mixed-mode program in which I create a new AppDomain...
3
2363
by: Jensen bredal | last post by:
Hello, I have an html submit button wich i have converted into a server control(ascx) . I want it serverside click event to be fired on "enter". How can this be achieved? Many thanks in advance JB
15
12547
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this property. Where is it? Or mabye change the other thing,No?Thanks ! Simon
1
1702
by: test | last post by:
Using a DetailsView to update data in SQL 2005, How do I change the default "Update" hyperlink to a more user friendly button? Thanks
10
10806
Shakss2
by: Shakss2 | last post by:
I have a form, where I can activate the search and replace dialogbox when pressing a button. My problem is that the dialogbox opens with the default that it should search for full match only, and I want it to open with default "a part of field". I did change it to default "A part of the field"? by going to Tools -> Options menu to open the "Options" dialog window. Select the "Edit/Find" tab. Select the "General Search" option button.
0
9563
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
9386
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
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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
6642
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();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.