Default Focus with the Login control and the Ajax RoundedCornersExtender

Last post 07-13-2009 11:16 AM by tmk8789. 14 replies.

Sort Posts:

  • Default Focus with the Login control and the Ajax RoundedCornersExtender

    06-29-2007, 10:19 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886

    I have a problem that either has a simple solution or is an Ajax bug - I don't know which.

    I've implemented the Login control inside a panel that has its corners enhanced by the RoundedCornersExtender.  It looks great but one negative side effect is that the initial focus is no longer in the UserName textbox.  Remove the extender and the problem goes away.

    Any ideas?

    Robert W.
    Vancouver, BC 

     

    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-03-2007, 4:56 AM

    Hi Robert,

    Can you show me a small, self-sufficient repro regarding this issue? 

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-03-2007, 12:45 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886

    Raymond,

    Greetings from the North end of the I-5 !!! :-)

    One perfect example of this can be found here: http://pocketpollster.com/beta/Login/login.aspx

    I looked for your e-mail address on here but can't find it.  You can e-mail me here:  A1 at PocketPollster dot Com

    And then I can send you the source files back.

    Robert


     

    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-03-2007, 10:44 PM

     Robert, I think it will be better if you post a simple demo here. All the community may benefit from this. :)

    I had a rough idea for solving your problem. Can you add a javascript function which will run on pageLoad? And set focus to the userName textbox in this method. For instance:

    function pageLoad()

    {

             window.setTimeout(setfocus, 1000);
     

    }

    function setfocus()

    {

            $get("the client id ").focus();
     

    }
     

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-03-2007, 11:40 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886

    Raymond,

    I will try your workaround but hopefully you can let the Ajax guys at MS know of this definite bug.  Here's the barebones of the code:
     

    <%@ Page Language="C#" MasterPageFile="~/main.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="_login" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <asp:Panel ID="panelLogin" runat="server" Height="250px" Width="270px" BackColor="#F9F9F9">
          <asp:Login ID="Login1" runat="server" BorderPadding="12">
            <TitleTextStyle HorizontalAlign="Left" VerticalAlign="Top" Height="40px" Font-Bold="true" Font-Size="Large" />
            <TextBoxStyle Width="140px" />
            <LoginButtonStyle Width="70px" />
          </asp:Login>
        </asp:Panel>
        <cc1:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="panelLogin" BorderColor="black" Radius="5" />
    </asp:Content>

     

      protected void Page_Load(object sender, EventArgs e)
      {
        // Make the Sign In button the default button and place the cursor in the User Name textbox
        if (!IsPostBack)
        {
          Page.Form.DefaultButton = Login1.FindControl("LoginButton").UniqueID;  // This works!
          Page.Form.DefaultFocus = Login1.FindControl("UserName").UniqueID;    // Doesn't currently work because of the Ajax RoundedCornersExtender control
        }
      }
     

     

    ----------------------------------------
    - End of Code -

     

    Robert

    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-04-2007, 12:21 AM

     http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=11520

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-04-2007, 12:58 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886
    Gracias, amigo!!
    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    08-03-2007, 7:07 PM
    • Member
      24 point Member
    • Jeremy.NET
    • Member since 10-26-2006, 2:37 AM
    • Posts 11

    Well, my app takes this one step further.  While this is related to the Ajax RoundedCornersExtender,  it is also aggravated by the Ajax TextBoxWatermarkExtender control as well.  Basically, I have a MasterPage with a LoginView control on it, and my content page (Register.aspx) is a 2-step CreateUserWizard process.  I managed to figure out how to handle the Default Button work around (LoginView login button was being defaulted), but then I came across the Focus issue.  Due to the fact that I have the TBWE control on the textboxes I want to focus, the Ajax controls are overriding my focus settings.  Using Raymond's workaround, I managed to be able to get Step 1 of my CreateUserWizard control to set the focus to my first textbox (though only 90% of the time).  The problem is that I then don't have any recourse on setting the focus of the first control on the second step since the load event is already set.  Any ideas?

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    10-03-2007, 6:53 AM
    • Member
      145 point Member
    • Ashiki
    • Member since 03-24-2006, 8:58 AM
    • Stamford, UK
    • Posts 43

    Shouldn't this now be fixed with the latest release - 10920? If so, I still have the problem.

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    10-03-2007, 3:00 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886

    I've been on holidays so wasn't aware that it was released ... and on my birthday no less!  The notes with the release do seem to indicate that the problem has been resolved.

    Robert
     

    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    10-04-2007, 5:22 AM
    • Member
      145 point Member
    • Ashiki
    • Member since 03-24-2006, 8:58 AM
    • Stamford, UK
    • Posts 43

    I have downloaded the latest release and I still get this issue. Without the RoundedCornersExtender I can set the focus in a textbox on page load, as soon as I put one on the page the focus doesn't work. Anyone else still having this issue or is something not right in my set up?

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    10-16-2007, 6:59 PM
    • Member
      678 point Member
    • rmdw
    • Member since 03-14-2005, 11:03 PM
    • Vancouver, BC, Canada
    • Posts 886

    I have now had the opportunity to test it too.  It definitely is NOT fixed.  I even went so far as to set the default focus to the actual (hard-coded) UserName control name but it did not work.  With the RoundedCornerExtender it does, so I'm convinced that the bug is not fixed.

     

    Robert Werner
    Vancouver, BC
    Technical Blog
    Pocket Pollster
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    03-13-2009, 11:05 PM
    • Member
      35 point Member
    • bfbishop
    • Member since 11-17-2006, 6:28 AM
    • Amarillo, TX
    • Posts 28

    rmdw:

    I have a problem that either has a simple solution or is an Ajax bug - I don't know which.

    I've implemented the Login control inside a panel that has its corners enhanced by the RoundedCornersExtender.  It looks great but one negative side effect is that the initial focus is no longer in the UserName textbox.  Remove the extender and the problem goes away.

    Any ideas?

    Robert W.
    Vancouver, BC 

     

    I know this post is a little dated, but I came across it today while searching for an answer to my own problem. It turns out that for me anyway, the problem wasn't specific to the RoundedCornersExtender or even to the Control Toolkit. It seems to be more of a problem with asp.net 3.5 and Ajax in general. Anyway, I found the solution to setting focus within the Ajax Control Toolkit. Here's what worked for me:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                AjaxControlToolkit.Utility.SetFocusOnLoad(myLogin.FindControl("UserName"))
            End If
        End Sub
    
     
  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    03-30-2009, 4:53 AM
    • Member
      8 point Member
    • Nomad88
    • Member since 03-30-2009, 8:52 AM
    • Posts 7

    This problem was killing me!  This definitely works!  Thanks a million!!! 

    Here is my updated solution...

    http://forums.asp.net/p/1404283/3050371.aspx#3050371

  • Re: Default Focus with the Login control and the Ajax RoundedCornersExtender

    07-13-2009, 11:16 AM
    • Member
      18 point Member
    • tmk8789
    • Member since 06-07-2009, 4:58 PM
    • Posts 57

    Brilliant!  Thank you!  What a pain to have to build a "workaround" for something that should be so simple!

Page 1 of 1 (15 items)