NOT have a default button?

  • Thread starter Thread starter Gregory Gadow
  • Start date Start date
G

Gregory Gadow

I have a large website written to use ASP.Net 2.0. The master page has a
"logout" button. If the child page does not have an explicitly defined
default button (most do not), the page posts back with the logout button
as the default, throwing the user out of the system.

I can supress all postbacks by putting "onsubmit='return false'" in the
form tag of the master page. That, however, renders all button clicks
and other postback calls non-functional. Is there a way in ASP.Net 2.0
to supress the concept of a default button entirely but still leave
buttons functional?
 
I managed to work out the solution I needed. To the javascript file already
being loaded by the master page, I added:

function NoEnterKey(e) {
var key;

if (window.event) key=window.event.keyCode;
else if (e) key=e.which;
else return true;

if (key==0x000D) return false; else return true;
}

Then in the form tag on the master page, I stuck in this:

onkeydown="return NoEnterKey(event);"

Seems to work! Thanks anyway.
 
Seems to work! Thanks anyway.

Is this a public web site? If so, some folks may not have javascript
enabled. Not sure if that will make a difference or not, but just a heads
up...

-Darrel
 
Back
Top