ModalPopupExtender with Textbox issue in Firefox

Last post 07-28-2008 7:01 AM by yrajasekhar. 11 replies.

Sort Posts:

  • ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 12:52 PM

    I’m using a modal popup with a login control (but just a textbox has same issue) which works ok in IE. When I test using Firefox the textbox will not get focus. I can’t place the cursor in the textbox however other controls (buttons and checkbox) work ok. The modal popup is being displayed via code behind or via button click with same issue and panel has an update panel surrounding the controls (textbox or login control). The site has a master page.

     

    I am hope that someone has a workaround or at least some suggestions for this issue. Idea

     

    Here is some sample markup which produces this issue...

     

       <asp:Panel ID="pnlLogin" runat="server" CssClass="modalPopup" style="display:none;">

          

           <asp:Panel ID="pnlLoginDrag" runat="server" Width="100%" Height="16px" 
     
                     BackColor="LightSteelBlue" style=" cursor:move;">           
            
    <span>
               
    <asp:Image ID="Image2" runat="server"
                          
    ImageUrl="~/Images/IconLib/security_16x16.gif" style ="float:left;" />
               
    <asp:Label ID="Label1" runat="server" Text="User Security" style="float:left;">
               
    </asp:Label>

                <asp:ImageButton ID="btnLoginCancel" BackColor="transparent" runat="server"

                                ImageUrl="~/Images/IconLib/delete_16x16.gif" 
                               
    style="float:right; cursor:pointer;" />
             </span>
      </asp:Panel>

          
    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"  >
               <ContentTemplate>

                <asp:Login ID="Login1" runat="server" TitleText="Login" LoginButtonText="Submit"

                           RememberMeSet="true" RememberMeText= "Remember me next time."

                           FailureText="Login failed! Please try again." 

                           OnLoggedIn="LogedIn"

                           style="margin-left:auto; margin-right:auto;" ></asp:Login>
     
               </ContentTemplate>

           </asp:UpdatePanel>

     

           <asp:Button ID="btnLoginNewUser" Text="New user registration." 

                       BorderStyle="None" BackColor="transparent" OnClick="btnLoginNewUser_Click"

                       style=" background-image:url(Images/IconLib/user1_(add)_16x16.gif);

                               background-repeat:no-repeat; float:left;  text-decoration:underline;

                               color:Blue; height:16px; vertical-align:middle; cursor:pointer;"  
                       
    runat="server" />
           <br />

           <asp:Button ID="btnLoginRecoverPassword" Text="Recover my password." 

                       BorderStyle="None" BackColor="transparent" OnClick="btnLoginRecoverPassword_Click"

                       style=" background-image:url(Images/IconLib/access_16x16.gif);

                               background-repeat:no-repeat; float:left;  text-decoration:underline;

                               color:Blue; height:16px; vertical-align:middle; cursor:pointer;"  
                       
    runat="server" />
           <br />
           <asp:Label ID="dummy" runat="server"></asp:Label>

      </asp:Panel>

      <asp:ModalPopupExtender ID="ModalPopupExtender" runat="server"
                              TargetControlID="btnLogin"
                              PopupControlID="pnlLogin"
                              BackgroundCssClass="modalBackground"
     
                             OkControlID="dummy"
                              CancelControlID="btnLoginCancel"
                              DropShadow="true"
                              PopupDragHandleControlID="pnlLoginDrag" />  

     

    Jerome C. Vernon
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 2:22 PM

    As it turns out; I can type data into the textbox (login control) but the cursor does not blink when the focus is on the textbox. There is no indication to the user that the textbox has focus.

    I attempted to surround the controls with a <div> and with overflow style prop set to 'hidden' - same issue.
    I also attempted to remove the update panel and drag pannel - same issue.

    The site that I am working on has many themes and removing all css overflow properities is not a good fix.

    After reading a bugzilla report and some other posts on this site, this issue appears to be a FireFox bug. Any suggestions or additional insight would be greatly appreciated.

    Jerome C. Vernon
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 2:29 PM

    The Login control is not compatible inside of updatepanels (unless its been converted to an editable template, which yours has not).  If you are trying to avoid refreshes, consider doing your authentication on the client-side.

    http://disturbedbuddha.wordpress.com/2007/11/19/a-client-side-ajax-login-for-aspnet/

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 2:36 PM

    Thanks DisturbedBuddha,

    But... The Login Control is not the issue. Logging in with the Login Control inside the ModalPopupExtender works great for me.

    Please note that this is an issue with any textbox control inside a ModalPopupExtender and with FireFox.

    Jerome C. Vernon
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 2:45 PM
    Answer
    • Member
      183 point Member
    • HoLLoW
    • Member since 05-15-2005, 1:27 AM
    • Un Mexicano En Brasil
    • Posts 86

    if you want to show focus, try this:

    In the Page, not the MasterPage:

    1    public clas YourPage :  System.Web.UI.Page
    2    { 
    4            private static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)
    5            {
    6                foreach (Control ctl in container.Controls)
    7                {
    8                    if ((onlyTextBoxes && ctl is TextBox) || ctl is TextBox || ctl is DropDownList ||
    9                        ctl is ListBox || ctl is CheckBox || ctl is RadioButton ||
    10                       ctl is RadioButtonList || ctl is CheckBoxList)
    11                   {
    12                       WebControl wctl = ctl as WebControl;
    13                       wctl.Attributes.Add("onfocus", string.Format("this.className = '{0}';", className));
    14                       wctl.Attributes.Add("onblur", "this.className = '';");
    15                   }
    16                   else
    17                   {
    18                       if (ctl.Controls.Count > 0)
    19                           SetInputControlsHighlight(ctl, className, onlyTextBoxes);
    20                   }
    21               }
    22           }
    23   
    24           protected override void OnLoad(EventArgs e)
    25           {
    26               SetInputControlsHighlight(this, "highlight", false);
    27   
    28               base.OnLoad(e);
    29           }
    30   
    31   }
    32   

    An put in you CSS style sheet...

    .highlight { background-color: #fefbd2; color: #000080; }

    life is lost in dreaming, dreaming is lost in becoming
    -----------------------------------------------------------
    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 2:46 PM

    This is a known bug in FireFox that occurs when certain objects overlap on the page due to absolute positioning.  The modal popup uses absolute positioning, which is what is causing this.  There is no fix that you can affect in your code.

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: ModalPopupExtender with Textbox issue in Firefox

    11-30-2007, 3:05 PM

    Thanks Hollow,

    Your example worked Very Good in swaping the background color to provide a visual indicator that a ModalPopup Textbox control has focus in Firefox.

    The cursor continues to not blink in FireFox. This however is now a smaller issue since there is at least nome some visual indication of focus-select with your fix.

    I would like to keep this case open since some others may have ideas on how to get the cursor to blink.

    Thanks -

    Jerome C. Vernon
  • Re: ModalPopupExtender with Textbox issue in Firefox

    04-30-2008, 11:57 AM
    • Member
      8 point Member
    • PeterFearn
    • Member since 04-30-2008, 3:56 PM
    • Posts 4

    Hi,

    I had a similar problem and have fixed it by using style="position: fixed" on the textbox.

    Pete

  • Re: ModalPopupExtender with Textbox issue in Firefox

    06-02-2008, 6:16 PM
    • Member
      635 point Member
    • dotnetbohn
    • Member since 01-25-2008, 7:29 PM
    • Posts 119

    I am having a similar issue as well.  It appears to be related to the div that creates the modal background effect.  Position:fixed also works for me, but if I scroll the page then the layout is messed up.

    Matt
    Chief Architect
    Software Engineer
    Smooth Fusion, Inc.
    http://www.smoothfusion.com
  • Re: ModalPopupExtender with Textbox issue in Firefox

    06-06-2008, 10:50 AM
    • Member
      635 point Member
    • dotnetbohn
    • Member since 01-25-2008, 7:29 PM
    • Posts 119

    I fixed by issue by creating wiring up the Ajax EndRequestHandler and adding some code to hide the background div for FireFox only.

    Matt
    Chief Architect
    Software Engineer
    Smooth Fusion, Inc.
    http://www.smoothfusion.com
  • Re: ModalPopupExtender with Textbox issue in Firefox

    07-03-2008, 5:27 AM
    • Member
      6 point Member
    • Michal Gorski
    • Member since 07-03-2008, 9:24 AM
    • Posts 3

    jeromevernon@sbcglobal.net:
    provide a visual indicator that a ModalPopup Textbox control has focus in Firefox.

     

    To provide that you can try to add attribute "onblur" with empty javascript action (or whatever) in your TextBox control. And set focus on your TextBox in code behind. I don't know why but it works.

     

    It should be in *.aspx:  

     

         <asp:TextBox onblur=""  ID="yourTextBox" runat="server" ></asp:TextBox>

     

    and in code behind that call popup:

                 popupPanel.Show();
                this.scriptManager.SetFocus(yourTextBox);
                yourTextBox.Focus();

     

    In addition, I can tell that the "yourTextBox" won't get the focus in some cases, but it's another issue...

     

     
  • Re: ModalPopupExtender with Textbox issue in Firefox

    07-28-2008, 7:01 AM
    • Participant
      1,802 point Participant
    • yrajasekhar
    • Member since 07-23-2008, 6:16 AM
    • Pune
    • Posts 247

    I achieved this by doing following things

    1. Remove Drag behavior from modalpopup i.e. remove PopupDragHandleControlID  attribute from modalpopup markup
    2. modalpopupextender creates a div element with id as <behaviourid>+"_backgroundElement" (for example if your behaviour id is "loginpopup" then div elements id will be "loginpopup_backgroundElement" (if you don't use behaviour id and you are using only id then id will be <modal popup client id>+"_backgroundElement" )
    3. Now just before displaying the popup set above div elements position to  'absolute'

    My javascript looks some thing like this

    function ShowSignUp(viewindex)
    {
        var bEle = document.getElementById('loginpopup_backgroundElement');
        if(bEle) bEle.style.position = 'absolute';
        $find('loginpopup').show();
    }

    when ever i want to show modal popup i call function ShowSignUp();

    My Blog
    dailyexpenses.info helps you to track when, where and why you have spent your money
Page 1 of 1 (12 items)