Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2007, 11:08 PM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
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

Reply With Quote
  #2 (permalink)  
Old July 3rd, 2007, 07:52 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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
================================================== =========
Reply With Quote
  #3 (permalink)  
Old July 4th, 2007, 10:09 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
Reply With Quote
  #4 (permalink)  
Old July 5th, 2007, 08:50 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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
================================================== =========
Reply With Quote
  #5 (permalink)  
Old July 8th, 2007, 09:35 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
Reply With Quote
  #6 (permalink)  
Old July 22nd, 2007, 02:58 PM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
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

Reply With Quote
  #7 (permalink)  
Old July 22nd, 2007, 08:21 PM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
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>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:40 AM.


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