Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2007, 11:08 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default Login Control Behavior when pressing ENTER

Ok...this is odd, I dropped a Login Control on the page. If I put in username and password and hit "enter" it just kicks me out...I "have" to click the login button for it to work. Any idea why?

Thanks,
Rob

 
Old July 3rd, 2007, 07:52 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I *think* this has to do with control focus. Normally, the desired result when a user clicks the 'Enter' key, is that a form automatically submits but I have ran into the same problem a few times.

My work around was a JavaScript that looked for the enter key to be pressed and just called [form].submit(); to post the form, not sure if that will work for what you are trying to do. (Obviously calling [form].sumbit() is just to easy, you will need to actually raise the buttons click event handler to do any processing on the server inside that event handler)



================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old July 4th, 2007, 10:09 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think this has to do with general form posting behavior. It is my understanding that when there is a single "submit" type html form input, pressing [Enter] equates to clicking that one submit. (This might be true for a image submit as well, not sure.) However, when you introduce a second "submit" type input, there is then no default submit clicked, or perhaps the default click is on the other submit. The end result is that the form posts, but with no (or the wrong) clicked input control. Every button on a web form is a submit input so check for other controls on this page.

A possible workaround for this problem is to use a different event for your login control. Instead of using the button click, you could use the username or password textbox OnTextChanged event. the only reason that event would fire would be if the user entered a username and password. Thus you should be able to safely assume that an event on one of those controls was an attempt to login by the user. The "login" button would not even need an event handler. It would serve purely as a method to cause a postback in the event the user didn't just hit [Enter].

-Peter
 
Old July 5th, 2007, 08:50 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

From a functional standpoint what Peter has suggested will work but remember, the OnTextChanged event will only fire after the control in question has lost focus.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old July 8th, 2007, 09:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I guess I wasn't entirely clear...

I am thinking of the server side OnTextChanged event. (Technically, there is no client side "OnTextChange" event, but rather the "onChange" event.)

Instead of using the server side button click, you could use the server side TextChanged event of either the password or username textbox.

-Peter
 
Old July 22nd, 2007, 02:58 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Sorry to repost..but could someone write what fucntion and where I would put it ? (using VB for my asp pages). I've tried several different places--can't seem to find something I can understand--I don't write hardly any Javascript on my pages---all asp coding.

THanks SO MUCH!
Rob

 
Old July 22nd, 2007, 08:21 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

FINALLY--got it!

Wrap the Login Control in a Panel and set the "DefaultButton" like I did below. I had to also set the DestinatinonPageUrl of the Login.

<asp:Panel ID="Panel1" runat="server" Width="125px" DefaultButton="Login2$LoginButton">

<asp:Login ID="Login2" runat="server" DisplayRememberMe="false" DestinationPageUrl="Admin/addpictures.aspx">
</asp:Login>

</asp:Panel>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Control behavior wirerider ASP.NET 2.0 Professional 0 October 3rd, 2006 05:14 PM
Pressing Enter should fire an event r_ganesh76 ASP.NET 1.0 and 1.1 Professional 4 September 28th, 2004 12:02 AM
How to send form data without pressing SUBMIT eapsokha Classic ASP Professional 2 March 1st, 2004 09:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.