The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

[OPEN] [#1406] [4.1.0] Problem with Button Menu and combo box inside of a user control

  1. #1

    [OPEN] [#1406] [4.1.0] Problem with Button Menu and combo box inside of a user control

    Started having this problem after the upgrade to 4.1. I have a dropdown inside of a control that is part of a Button / Menu. When you click the Button / Menu, the combo shows up but when you click it to start typing it disappears. The same combo box outside of the context of a user control works fine.

    User Control
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="QSearch.ascx.vb" Inherits="Adhesion.Web.QSearch" %>
    
    <ext2:ComboBox 
        ID="Results" 
        runat="server" 
        ValueField="Key"
        TypeAhead="false" 
        LoadingText="Searching..."
        HideTrigger="true" 
        EmptyText="Type to Search" 
        QueryDelay="1500" 
        QueryCaching="false"
        MinChars="1" 
        Border="false"
        Width="920" 
        Height="38">
     </ext2:ComboBox>
    Main Page
    <%@ Page Language="vb" %>
    <%@ Register TagPrefix="uc" TagName="QuickSearch" Src="QSearch.ascx" %>
    
     <script runat="server">
    
         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         End Sub
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Simple Combo</title>
        <script type="text/javascript">
        </script>
    </head>
    <body>
     
        <ext2:ResourceManager ID="ResourceManager" runat="server" />
    
        <ext2:Window ID="Window1" runat="server" Visible="true" Maximized="true" Padding="5" Resizable="true" MinHeight="700" MinWidth="500" Closable="false">
            <TopBar>
                <ext2:Toolbar ID="Toolbar1" runat="server">
                    <Items>
    
                        <ext2:Button ID="QuickLaunchReport" runat="server" Text="This does not work" >
                            <Menu>
                                <ext2:Menu ID="QuickLaunchReportMenu" runat="server" RenderToForm="true" Width="450" ShowSeparator="false">
                                    <Items>
                                        <ext2:Panel runat="server">
                                            <Content>
                                                <uc:QuickSearch ID="QuickSearch" runat="server" />
                                            </Content>
                                        </ext2:Panel>
                                    </Items>
                                </ext2:Menu>
                            </Menu>
                        </ext2:Button>
    
                        <ext2:Button ID="Button1" runat="server" Text="This works"  >
                            <Menu>
                                <ext2:Menu ID="Menu1" runat="server" RenderToForm="true" Width="450" ShowSeparator="false">
                                    <Items>
                                        <ext2:Panel runat="server">
                                            <Items>
                                                <ext2:ComboBox 
                                                    ID="works" 
                                                    runat="server" 
                                                    ValueField="Key"
                                                    TypeAhead="false" 
                                                    LoadingText="Searching..."
                                                    HideTrigger="true" 
                                                    EmptyText="Type to Search" 
                                                    QueryDelay="1500" 
                                                    QueryCaching="false"
                                                    MinChars="1" 
                                                    Border="false"
                                                    Width="920" 
                                                    Height="38">
                                                </ext2:ComboBox>
                                            </Items>
                                        </ext2:Panel>
                                    </Items>
                                </ext2:Menu>
                            </Menu>
                        </ext2:Button>
                    </Items>
                </ext2:Toolbar>
            </TopBar>
    
            <Items>
                <ext2:Panel ID="pnlSetDefaults" runat="server">
                   <Items>
      
                   </Items>
                </ext2:Panel>
            </Items>
        </ext2:Window>
    
    </body>
    </html>
  2. #2
    Hello @rmelacon!

    Thanks for providing the test case. The problem is not related to user controls, try just renaming the Items block to Content in your working sample. It will break just as the same. So the problem is adding the combobox (or maybe any focusable control/field) inside the drop down menu via Content blocks.

    We'll further check if there's a feasible solution for this and/or why this started to happen since 4.1 release.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello again @rmelacon!

    I just found a way that will probably work for you just fine. It involves adding the custom control inside the Items collection.

    1. remove the 'register' line from your page.
    2. add the user combo box like this in your menu (replace the Content block with this):

    <Items>
        <ext:UserControlLoader runat="server" UserControlID="QuickSearch" Path="QSearch.ascx" />
    </Items>
    Anything inside Content tags are failing the focus handling for some reason and for that we opened an issue to investigate it under #1406.

    Added there a simplified test case with only the required elements to reproduce the issue. Seems you left in a considerable amount of code that are not required to reproduce the issue (additionally to the user control, that is).

    Hope the alternative above works for you!
    Fabrício Murta
    Developer & Support Expert
  4. #4
    Trying that out but having a problem in that I am setting properties of the control in the code behind and the object (control) doesn't seem to be instantiated. So in my Page_Load I am trying to set properties like QuickSearch.EmptyText = "some text" along with some other properties and I get the standard "Object reference not set to an instance of an object". So what is the proper way to access that controls properties when using the control loader method, ie when does it get instantiated?

    I tried using the "OnDataBinding=" but the sub never gets called.
    Last edited by rmelancon; Jan 09, 2017 at 7:06 PM.
  5. #5
    Ops! I forgot to move the thread to the 'bugs' forum and tag it accordingly.

    Alright, I believe you need to indirectly reference to the component then.

    For what we have in your sample combo box control, one way to get it from code behind during page load is:

    var cb = X.GetCmp<ComboBox>("Results");
    I hope this helps. I'll ask you we leave this thread for the bug/limitation initially reported (no <Content /> support in menu's list of <Items />), so if you have more problems custom control-related or other than this, would you mind creating a new thread from this point on?
    Fabrício Murta
    Developer & Support Expert
  6. #6
    Will do. Thanks.

Similar Threads

  1. Replies: 2
    Last Post: May 09, 2013, 4:41 PM
  2. Replies: 5
    Last Post: Jan 15, 2013, 6:11 PM
  3. Replies: 2
    Last Post: Feb 06, 2012, 10:06 AM
  4. Create control user with menu button
    By vincent in forum 1.x Help
    Replies: 0
    Last Post: Jan 11, 2011, 11:12 AM
  5. Replies: 3
    Last Post: May 11, 2010, 11:36 AM

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.