?
Solved

ASP.NET Login Control default button

Posted on 2007-07-24
8
Medium Priority
?
781 Views
Last Modified: 2012-05-05
I have created a form with the login control on it.  I changed the button to include an image so it stands out better.  Now I want to make the login the default button when the user hits the ENTER key.  In other forms I just use Page.Form.DefaultButton = LoginButton.UniqueID in the laod event.  However, since the login button is within the login control I cannot acces it from the form level.  

Does anyone know how to have the login button within the login control the default button on the page??
0
Comment
Question by:akobes05
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Assisted Solution

by:ggable313
ggable313 earned 200 total points
ID: 19559306
Just in case another solution doesnt fit, here is javascript to semi-accomplish what you are wanting.  It checks for the enter key being pressed.  In my usage I wanted the Enter key NOT to work.  Therefore the returnValue was false and the cancel was true.  However, I changed the returnValue to true and cancel to false for your usage.  I dont know if either/both/only one of them is needed, but you can play around with it a bit to see.  Hope it helps! :)

<script language="javascript" type="text/javascript">
          this.document.onkeypress = function() {
              if (window.event.keyCode == 13) {
                                  alert('You have hit the enter key.');
                                  event.returnValue=true;
                                  event.cancel = false;
              };
          };
      </script>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19559320
The default UniqueID for the Login control is "Login1$LoginButton":

    Page.Form.DefaultButton = "Login1$LoginButton"

Bob
0
 

Author Comment

by:akobes05
ID: 19559338
Thanks, this woudl work if it was a regular button control.  However, since the login button on the login control is nested I cannot use the java script.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:akobes05
ID: 19559360
Page.Form.DefaultButton = "Login1$LoginButton"  does nto work, I get the following error:

DefaultButton of 'frmLogin' must be the ID of a control of type IButtonControl.
0
 
LVL 16

Accepted Solution

by:
TSmooth earned 900 total points
ID: 19559422
Page.Form.DefaultButton = DirectCast(Login1.FindControl("LoginButton"), Button)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19559426
Can you show me how the Login control is rendered?  Have you modified the Login control so that it is not the default configuration?

Bob
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 900 total points
ID: 19559439
This is the dynamic way:

    Dim button As Button = Me.Login1.FindControl("LoginButton")
    Page.Form.DefaultButton = button.UniqueID

Bob
0
 
LVL 16

Expert Comment

by:TSmooth
ID: 19559552
I see that my solution is the same as Bob's latest one but I forgot to include the ".UniqueID" on the end by mistake :(
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question