Home All Groups Group Topic Archive Search About
Author
15 Feb 2005 9:03 AM
news

Can I use ENTER to submit my form using C#?

I have used
Page.RegisterHiddenField("__EVENTTARGET", "btnFind");



This works SOMETIMES but not all the time.



I saw



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsformclassactivatedtopic.asp



and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassgotfocustopic.asp



which explains that ENTER is not used since the Activate is used for Forms.
I understand the logic but I still cant get my forms to always submit on
ENTER and instead it uses the first control (a list) and ends up being
redirected.



Enter has been used for decades to submit a request dating back to "dumb
terminals" and even typewriters. So it makes sense to use the ENTER to
submit forms.

Author
15 Feb 2005 11:34 AM
Dmitriy Lapshin [C# / .NET MVP]
Hi,

As far as ASP .NET forms are concerned (the MSDN article you're referring to
speaks about Windows Forms which are quite a different technology having
nothing to do with Web programming), there is a special type of the <INPUT>
control - <INPUT TYPE="Submit">. This control corresponds to the
System.Web.UI.WebControls.Button control in ASP .NET. Just make sure not to
define the CommandName and OnCommand properties on the Web form for the
button control to be rendered as the submit and not a command button.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Show quoteHide quote
"news" <sa***@logicians.com> wrote in message
news:CViQd.14994$8B3.2362@text.news.blueyonder.co.uk...
> Can I use ENTER to submit my form using C#?
>
> I have used
> Page.RegisterHiddenField("__EVENTTARGET", "btnFind");
>
>
>
> This works SOMETIMES but not all the time.
>
>
>
> I saw
>
>
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsformclassactivatedtopic.asp
>
>
>
> and
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassgotfocustopic.asp
>
>
>
> which explains that ENTER is not used since the Activate is used for
> Forms.
> I understand the logic but I still cant get my forms to always submit on
> ENTER and instead it uses the first control (a list) and ends up being
> redirected.
>
>
>
> Enter has been used for decades to submit a request dating back to "dumb
> terminals" and even typewriters. So it makes sense to use the ENTER to
> submit forms.
>
>
Are all your drivers up to date? click for free checkup

Author
15 Feb 2005 3:47 PM
Alvin Bruney [MVP]
here is a gem
http://www.allasp.net/enterkey.aspx

--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------


Show quoteHide quote
"news" <sa***@logicians.com> wrote in message
news:CViQd.14994$8B3.2362@text.news.blueyonder.co.uk...
> Can I use ENTER to submit my form using C#?
>
> I have used
> Page.RegisterHiddenField("__EVENTTARGET", "btnFind");
>
>
>
> This works SOMETIMES but not all the time.
>
>
>
> I saw
>
>
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsformclassactivatedtopic.asp
>
>
>
> and
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassgotfocustopic.asp
>
>
>
> which explains that ENTER is not used since the Activate is used for
> Forms.
> I understand the logic but I still cant get my forms to always submit on
> ENTER and instead it uses the first control (a list) and ends up being
> redirected.
>
>
>
> Enter has been used for decades to submit a request dating back to "dumb
> terminals" and even typewriters. So it makes sense to use the ENTER to
> submit forms.
>
>

Bookmark and Share