Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 The final furlong

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-07-11 : 12:53:12
I've written a small ASP.NET 1.1 app. That works quite well, which I'm pleased about.



The only fly in this ointment is this. The app uses forms authentication. for the login part of the forms authentication I have a user control (nothing unusual I think).

My problem is the default button. I use

Page.RegisterHiddenField("__EVENTTARGET", butLogin.ClientID)

to set the default button (i.e. when Enter is pressed). If I put this line in the User control it works BUT clicking on the button with the mouse doesn't.

If instead I put this line into the main page

Page.RegisterHiddenField("__EVENTTARGET", PICKStartLogin.LoginButton.ClientID)

Then the login functionality stops working.

Just to add insult to injury, the original symptoms were that the first time you entered your login and password and then pressed enter, all that happened was that the boxes cleared, but the second time it worked as expected. I suspected that was to do with postback but didn't get to the bottom of it.



I'd be grateful for any comments or advice



thanks



steve


-----------

Don't worry head. The computer will do all the thinking from now on.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-07-11 : 16:34:27
Regular HTML will let you do what you want, no need to mess with those ASP.NET hidden fields ....

If you ensure that you only have 1 HTML "submit" button on the page, then it will automatically be your default when ENTER is pressed. Just be sure that if you have *other* buttons on the page (i.e., a CANCEL button) that your other buttons are *not* submit buttons, just regular ones.

i.e., in your ASP page, have something like this:

<asp:Button runat="server" id="bSubmit" text="Submit"/>
<br>
<Button runat="server" id="bCancel" type="Button">Cancel</Button>

The first produces a submit button, the second a regular button. But note that you can still create a "server_click" even for that second button, even though it is not an HTML submit button. The result of this is that you now have only 1 submit button and that should be the one that is "pressed" when you hit ENTER.

- Jeff
Go to Top of Page
   

- Advertisement -