[CLOSED] Referencing Controls in a UserControls - two UCs on same page

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Referencing Controls in a UserControls - two UCs on same page

    I know I have touched on this subject several times, and I did have a look through my previous posts but I couldnt find a question specifically about this so here goes:

    I have one Page and on that page I place two UserControls of the same type/class, MyUserControl.

    In MyUserControl I have lets say three ComboBoxes, C1, C2 and C3.

    When I select a value in C1, I want to shift focus to C2 in the same UserControl (I know that in reality there is no such thing as a UserControl when the page is rendered). Setting that focus works fine when there is only one instance of the UserControl on the Page.

    However, when I have two (or more) UserControls on the same Page, the focus is not shifted to C2 in the same UserControl, but to C2 in the last UserControl. This is because the ClientId (or something like that) is "overwritten" by the last Control somehow.

    The question is: how do I make it focus C2 in the same UserControl?

    Here is the JS function that shifts the Focus:

    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
          
            function checkValue() {
                var id = this.getValue();
                if (id > 1)
                     #{C2}.focus();
            }
       </script>
    </ext:XScript>
    And the ComboBoxes (in the UserControl):
    <ext:ComboBox runat="server" EmptyText="Test1" Icon="ShapeHandles" AutoWidth="true"
        ID="C1"
        DisplayField="Name"
        ValueField="Id" 
        TypeAhead = "false" HideTrigger = "false" EnableKeyEvents = "true" MinChars = "2" LoadingText="Searching..." ForceSelection="false">
        <Store>
            <ext:Store ID="MyStore" runat="server" AutoLoad="false" OnRefreshData="MyStore_Refresh">
                <Proxy>
                    <ext:PageProxy />
                </Proxy>
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="Id" />
                            <ext:RecordField Name="Name" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
        <Listeners>
            <Select Fn="checkValue" />
        </Listeners>
    </ext:ComboBox>
    
    
    <ext:ComboBox runat="server" EmptyText="Test2" Icon="ShapeHandles" AutoWidth="true"
        ID="C2"
        DisplayField="Name"
        ValueField="Id" 
        TypeAhead = "false" HideTrigger = "false" EnableKeyEvents = "true" MinChars = "2" LoadingText="Searching..." ForceSelection="false">
        <Store>
            <ext:Store ID="MyStore2" runat="server" AutoLoad="false" OnRefreshData="MyStore2_Refresh">
                <Proxy>
                    <ext:PageProxy />
                </Proxy>
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="Id2" />
                            <ext:RecordField Name="Name2" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
    </ext:ComboBox>
    Last edited by Daniil; May 03, 2011 at 9:52 AM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] Referencing page controls in JavaScript objects
    By PLoch in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Aug 16, 2011, 5:59 PM
  2. Replies: 14
    Last Post: Apr 12, 2011, 2:49 PM
  3. Replies: 4
    Last Post: Apr 04, 2011, 8:54 AM
  4. [CLOSED] [1.0] Referencing User Controls using #{}
    By bsnezw in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2010, 10:59 AM

Tags for this Thread

Posting Permissions