How do disable button selection on a page.

  • Thread starter Thread starter Lily
  • Start date Start date
L

Lily

Hi there,
I have several buttons and one datagrid on a page.

Whenever I click on the page anywhere, one of the buttons is selected
(without actually been clicked on), now if I press "Enter" key, the
button's click event got called.

This is a major problem for me!!

I guess this is a feature of ASP.NET. But how could I disable it???
Thanks ahead.
 
Lily,

This is actually a feature of the Web browser, not ASP.NET. In order to
stop that, you will need to use some client-side code.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 
Lilly, I posted to this last night, but don't see the reply. I remember
how frustrating it was to deal with this issue, so I'm replying again.

I worked around this issue by adding a tiny button with
(visible/validation set to false) to my page. Then make sure that button
control comes BEFORE any other event controls in your HTML. Since there
is no code behind this button, it does nothing, but is used as the
default for the enter key, etc.

example: (you can use it on any page as needed)

<asp:button id="btn_UsedAsDefault" style="Z-INDEX: 126; LEFT: 8px;
POSITION: absolute; TOP: 8px" runat="server" Width="1px"
BackColor="Transparent" BorderColor="Transparent" Height="1px"
ForeColor="Transparent" CausesValidation="False"
Visible="False"></asp:button>

Hope this helps.
Kat
 
Lily,

Sorry but I had an error in what I posted. Leave the button visible =
true. That's why I made it tiny and transparent. If visible = false,
does not work.

Kat
 
Ha, good idea! Thanks for that.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 
Back
Top