ASP.NET 2.0 - Enter Key - Default Submit Button

Rate It (3)

Last post 04-28-2008 8:02 AM by ShivaKarthik. 56 replies.

Sort Posts:

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    01-04-2008, 6:34 AM

    bachbouch:

    For those who are using the .Net 2.0 login control, I just thought about a hacky way to implement the scenario where users can hit the Enter key to fire the login button event, here is how it works:

    1- wrap your login control into a Panel and call it Panel1.

    2- inset a button on stage and call it dummyButton, set it's width and height  to 0, set it border to none and it is background anad foreground to white set it is text to empty string.( this is way, dummybutton will be invisible). If you are wondering why wouldn't I just set the visibility to false, well the answer is that it won't work.

    3- set the defaultbutton of Panel1 to dummyButton and set put this code the dummyButton your click handler

    bool crediteUser = Membership.ValidateUser(Login1.UserName, Login1.Password);

    if (crediteUser)

    {

    FormsAuthentication.RedirectFromLoginPage(Login1.UserName,false);

    }

     

    Hope this helps

     

     

     I think I have a even better solution for the Default Enter Key in Login Control. You don't need to write any code. Just follow the following steps:

    1.  Convert the Login control into a template by selecting the control and clicking the the arrow button on the top right corner and select "Convert to Template".
    2.  In your Login control template design view, add a Panel into the template and put everything in the Login control into the Panel.
    3.  When you convert your Login control to a template, the submit button in the Login control is now separated out. Select on the submit button to find out its name and fill the name into the DefaultButton property of the Panel inside the Login control template.

     Problem solved.

     


     

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    01-16-2008, 5:48 AM
    • Loading...
    • parcol
    • Joined on 01-16-2008, 10:42 AM
    • Posts 1

    coolbear_lq@hotmail.com:

     I think I have a even better solution for the Default Enter Key in Login Control. You don't need to write any code. Just follow the following steps:

    1.  Convert the Login control into a template by selecting the control and clicking the the arrow button on the top right corner and select "Convert to Template".
    2.  In your Login control template design view, add a Panel into the template and put everything in the Login control into the Panel.
    3.  When you convert your Login control to a template, the submit button in the Login control is now separated out. Select on the submit button to find out its name and fill the name into the DefaultButton property of the Panel inside the Login control template.

     Problem solved.

     

     

    This does the job with indead minimal coding.

    To set the focus to the username textbox I added the following code to the Page_Load:

    TextBox userName = (TextBox)Login1.FindControl("UserName");
    userName.Focus();

    This works for me. 

     

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    01-22-2008, 1:31 AM
    • Loading...
    • India.net
    • Joined on 01-22-2008, 5:09 AM
    • Posts 3

    hi everyone , I am also having the same problem and tried all the solutions but they r working only for single text box.if i set defaultbutton property of a form then it works for first text box only. also i have tried other solutions ,plz suggest some solution.Idea

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    01-22-2008, 2:47 AM
    • Loading...
    • rmdw
    • Joined on 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 369

    I don't understand what you're trying to say.  An example would help as a starting point.

    I invite you to visit this page: http://pocketpollster.com/beta/Feedback/infoRequest.aspx   It works properly for my needs.  How close is yours to it?

    Robert 

    Robert Werner
    Vancouver, BC
    www.pocketpollster.com/beta
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    01-22-2008, 5:18 AM
    • Loading...
    • zirmandli
    • Joined on 05-22-2007, 5:45 AM
    • Ahmedabad, India
    • Posts 74

    Hi

    to make button to default button for the page, try this

    Page.Form.DefaultButton = btnSubmit.UniqueID;

     

    Click on 'Mark as Answer' if this post is helpful.

    -- Benazir Mandli
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    02-18-2008, 11:31 AM

    I to face this problem in program. but i'm using master page. when i open another webform and enter the hit button it executes the master page button , but it supposed to execute current webform button

    thnks n regards,
    Maran.

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    03-26-2008, 5:05 AM

    i had the same problem and tried the code you suggested...i got the error below;

    Error 1 The name 'Login1' does not exist in the current context C:\inetpub\wwwroot\wbsa\index.aspx.cs 18 35 http://localhost/wbsa/
     

     

     

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    03-26-2008, 7:09 AM

    Hi Parcol,

    Can you show me some code on your panel workaround?

    I tried your suggestions and it gave me some errors.

    Thanks

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    04-24-2008, 3:27 AM
    • Loading...
    • zubinjoshi
    • Joined on 02-23-2008, 7:37 AM
    • Delhi India
    • Posts 58

    how this can be solved in .net 1.1

    suppose there are two frame one for new login and another for existing login ........ with 2 textboxes and one button in each frame...

    when user mouse is in the perticular textbox the corresponding button should fire ,,, as that we have in .net 2.0 through defaultbutton in div

    how can be done in .net 1.1

     

     

     

    Mark it Answer if it helps you :)
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    04-24-2008, 3:38 AM

    Set default button as new login for frame1 and existing login for frame 2  

    thnks n regards,
    Maran.

  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    04-24-2008, 6:17 AM

    Hi Friend,

    Just use access key property to do that

    With Friendly,
    Thirumaran

    Please remember to click "Mark as Answer" on this post if it helped you
  • Re: ASP.NET 2.0 - Enter Key - Default Submit Button

    04-28-2008, 8:02 AM
    • Loading...
    • ShivaKarthik
    • Joined on 04-15-2008, 1:11 PM
    • Hyderabad
    • Posts 155

    No Need Of this  much of stuff.Just u can do in the following way

     //the button which you want as default button define it in defaultbutton

    <form id="form1" runat="server" defaultbutton= "btn_Submit">

    Regards,
    B.ShivaKarthik
    Software Engineer
    Hyderabad,India
Page 4 of 4 (57 items) < Previous 1 2 3 4