PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

Default Button for Enter Key on Web Form

 
 
Fred Nelson
Guest
Posts: n/a
 
      3rd Dec 2005
Hi:

I'm a relative newby and I'm writing a C# web application in VS2005.

I have several forms with multiple buttons. In 95% of the cases users
will click a particular button.

I would like to allow them to press the enter key if they are selecting
the "95% of the time" button.

I have tried the "AccessKey" property. If I set the value to "1" then
the button's click event is fired if the user presses ALT-1.

Is there a way to do this for the enter key?

Your help will be GREATLY appreciated!

Thanks,

Fred

 
Reply With Quote
 
 
 
 
Zeya
Guest
Posts: n/a
 
 
Reply With Quote
 
Joshua Flanagan
Guest
Posts: n/a
 
      4th Dec 2005
Those solutions are now obsolete/unnecessary with ASP.NET (original post
mentioned use of VS2005).

There is a new DefaultButton property on the Form and Panel controls.

http://msdn2.microsoft.com/en-us/lib...ultbutton.aspx

http://msdn2.microsoft.com/en-us/library/d6a7tey4(en-US,VS.80).aspx


Joshua Flanagan
http://flimflan.com/blog



Zeya wrote:
> Check this link it is pretty good:
>
> http://www.kamp-hansen.dk//document.aspx?id=28
>
> http://weblogs.asp.net/pleloup/archi.../09/86794.aspx
>

 
Reply With Quote
 
Fred Nelson
Guest
Posts: n/a
 
      4th Dec 2005
Hey Folks:

Thanks for your help - it pointed me in the right direction!

I have found that it is very easy to insert lines in the page_load event
to define the default focus and the default button:

Page_Load(..)
{
Page.Form.DefaultButton = btnEnter.UniqueID;
Page.Form.DefaultFocus = tbxInputField.UniqueId;
}

It works perfectly AND it's only two lines of code!

Thanks for your help!

Fred


Joshua Flanagan wrote:

> Those solutions are now obsolete/unnecessary with ASP.NET (original post
> mentioned use of VS2005).
>
> There is a new DefaultButton property on the Form and Panel controls.
>
> http://msdn2.microsoft.com/en-us/lib...ultbutton.aspx
>
> http://msdn2.microsoft.com/en-us/library/d6a7tey4(en-US,VS.80).aspx
>
>
> Joshua Flanagan
> http://flimflan.com/blog
>
>
>
> Zeya wrote:
> > Check this link it is pretty good:
> >
> > http://www.kamp-hansen.dk//document.aspx?id=28
> >
> > http://weblogs.asp.net/pleloup/archi.../09/86794.aspx
> >


 
Reply With Quote
 
Zeya
Guest
Posts: n/a
 
      6th Dec 2005
Yes, this is an option. But note this option is available with ASP.Net
2.0.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Button Click On Enter KeyPress On Web Form Joey Microsoft ASP .NET 1 28th Feb 2007 04:12 PM
Form Submit button--How to remove default Enter? B Tuohy Microsoft Frontpage 2 12th Mar 2005 06:40 AM
default button on enter bart pannemans Microsoft Access Forms 2 1st Feb 2005 07:05 PM
how to change default ENTER key behaviour on a button/form Flip Microsoft ASP .NET 2 18th Nov 2004 04:21 AM
Re: default button and enter Anton ml. Vaheie Microsoft ASP .NET 0 31st Dec 2003 08:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 AM.