473,323 Members | 1,550 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,323 software developers and data experts.

accessibility and asp:button

JV
This is for anyone who has tackled the accessibility issue on their web site
(and if you haven't, I bet you will in future).

Apparently the asp:button control always renders as '<input type="submit"
....' (a.k.a. submit button) and this can have a big impact on your web
site's keyboard handling. Default IE behavior when you have the keyboard
focus on an edit field is to find the first submit button and trigger a
click event on it (NOTE: Submit buttons behave similarly to a default
button in a Windows GUI application -- often the "Ok" button -- so their
border is drawn darker to indicate that they are the default for that form.
Of course, blind people cannot detect that, but hey...).

Anyway, if you use multiple asp:button controls on your web form, the ENTER
key's behavior may surprise your users. Did you put a LOGIN/LOGOUT button
on all of your pages? Maybe ENTER logs them out instead of clicking the
SUBMIT button you expected it to click.

So, it's probably not a good idea to use the asp:button control more than
once on your form, and then only for the most obvious, sensible default
button.

Has anyone else run into this?

--JV

P.S. Before you freak out, keep in mind this only applies when keyboard
focus is on an edit field. If it is on a button or hyperlink, default
behavior is to click that button or hyperlink.
Nov 19 '05 #1
3 2040
I ran in similar situation when I was designing the City of North Vancouver
website www.cnv.org

Many of the online forms have different sections, typically: the site search
section and the application section. I used the following JavaScript in
every textbox to associate it with a specific button:

function fnTrapKD(btn){
if (document.all){
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
}

For the site search textbox, I add the attribute:
onkeydown="fnTrapKD(document.all.btnSearch)"

For other textboxes within any form I pass the button ID that would submit
the section, which in turn would cause the postback event to be triggered.

---

www.webswapp.com

www.societopia.net

"JV" <jo**********@goisc.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
This is for anyone who has tackled the accessibility issue on their web site (and if you haven't, I bet you will in future).

Apparently the asp:button control always renders as '<input type="submit"
...' (a.k.a. submit button) and this can have a big impact on your web
site's keyboard handling. Default IE behavior when you have the keyboard
focus on an edit field is to find the first submit button and trigger a
click event on it (NOTE: Submit buttons behave similarly to a default
button in a Windows GUI application -- often the "Ok" button -- so their
border is drawn darker to indicate that they are the default for that form. Of course, blind people cannot detect that, but hey...).

Anyway, if you use multiple asp:button controls on your web form, the ENTER key's behavior may surprise your users. Did you put a LOGIN/LOGOUT button
on all of your pages? Maybe ENTER logs them out instead of clicking the
SUBMIT button you expected it to click.

So, it's probably not a good idea to use the asp:button control more than
once on your form, and then only for the most obvious, sensible default
button.

Has anyone else run into this?

--JV

P.S. Before you freak out, keep in mind this only applies when keyboard
focus is on an edit field. If it is on a button or hyperlink, default
behavior is to click that button or hyperlink.

Nov 19 '05 #2
JV
That would certainly work, and I could see doing that on sites with not too
many forms, but on some sites it seems like that could turn into a lot of
extra coding to tie that to every focusable control that is neither button
nor hyperlink.

"societopia.net" <so********@societopia.net> wrote
I ran in similar situation when I was designing the City of North Vancouver
website www.cnv.org

Many of the online forms have different sections, typically: the site
search
section and the application section. I used the following JavaScript in
every textbox to associate it with a specific button:

function fnTrapKD(btn){
if (document.all){
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
}

For the site search textbox, I add the attribute:
onkeydown="fnTrapKD(document.all.btnSearch)"

For other textboxes within any form I pass the button ID that would submit
the section, which in turn would cause the postback event to be triggered.

Nov 19 '05 #3
The function fnTrapKD cost is only 8 lines of code that are shared by the
entire page. Then in each textbox the only additional code is the function
all: onkeydown="fnTrapKD(document.all.btnSearch)"

You can also make a variation of that function for other boxes where you
want the return key to cause the focus to be set to a subsequent textbox
instead of to submit the form.

---

"JV" wrote:
That would certainly work, and I could see doing that on sites with not too
many forms, but on some sites it seems like that could turn into a lot of
extra coding to tie that to every focusable control that is neither button
nor hyperlink.

"societopia.net" <so********@societopia.net> wrote
I ran in similar situation when I was designing the City of North Vancouver
website www.cnv.org

Many of the online forms have different sections, typically: the site
search
section and the application section. I used the following JavaScript in
every textbox to associate it with a specific button:

function fnTrapKD(btn){
if (document.all){
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
}

For the site search textbox, I add the attribute:
onkeydown="fnTrapKD(document.all.btnSearch)"

For other textboxes within any form I pass the button ID that would submit
the section, which in turn would cause the postback event to be triggered.


Nov 19 '05 #4

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

Similar topics

1
by: RSB | last post by:
Hi Every one, Having tuff time to make this work .. i want to have a button and on my form say Delete button. So once i click on it i want to confirm "Are you sure?" on the Client Side and if...
11
by: Frag | last post by:
Hi guys, I searched around without any clear answer. Tons of stuff, but nothing concrete. I am trying to call this Javascript function: function ButtonClicked() { alert("The button has...
0
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following shopping cart (basket view). However, Delete button in my datagrid doesn't fire any events. Does anyone know why? (It's a user web control) <%@ Control...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
4
by: hb | last post by:
Hi, When I add an asp:button (ex: id=btnLog) on home.aspx, I need to create btnLog_Click() event in home.aspx.cs, and also link this event and the button in OnInit() method by adding:...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
4
by: Sean | last post by:
I have a situation whereby I need to modify the text string appearing on an ASP button with some text derived from a Javascript function. But I am unsure of the correct syntax to do so. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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

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.