[CLOSED] UserControl breakout

Threaded View

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

    [CLOSED] UserControl breakout

    I am in the process of refactoring my code to break things apart. Here is a simple example of what I am trying to accomplish.

    I am very weak in this area of coding.

    I have a page (aspx) that based on a request type (Cat1 or Cat2) needs to populate a container with one of two user controls. The actual application has a lot more category choices and the user controls are not all comboboxs but contain various controls, but this should be a simple example to ask the question.

    How can I populate the correct control (I have that working) and how when I click on description button can I ask the control to build a string representing the various control values?

    OptionPage03.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        [DirectMethod]
        public static String LoadOptionsUserControl(Dictionary<string, object> extraParams)
        {
            var reqType = extraParams["ReqType"];
            return ComponentLoader.ToConfig(String.Format("Options{0}.ascx", reqType));
        }
    
        protected void ClickBuildDescription(object sender, DirectEventArgs e)
        {
            // Would like to be able to ask the user control (Options01 or Options02) to
            // return a description of what was selected in their control.  Each control
            // calculates the description a little differently.
            
            String description = "How to call the control and have it return a description?";
            X.Msg.Alert("Description from user control", description).Show();
        }
    </script>
    <!DOCTYPE html >
    <html>
    <head id="Head1" runat="server">
        <title>Load UserControls</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Viewport runat="server" Layout="BorderLayout">
            <Items>
                <ext:FormPanel runat="server" Region="North">
                    <Items>
                        <ext:RadioGroup ID="RequestTypesGroup" runat="server" FieldLabel="Request Types"
                            ColumnsWidths="100,100" AllowBlank="false">
                            <Items>
                                <ext:Radio runat="server" Name="Group" BoxLabel="Cat1" InputValue="01" />
                                <ext:Radio runat="server" Name="Group" BoxLabel="Cat2" InputValue="02" />
                            </Items>
                        </ext:RadioGroup>
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" Text="Load" Icon="PluginGo" FormBind="true" Disabled="true">
                            <Listeners>
                                <Click Handler="App.ContainerOptions.load();" />
                            </Listeners>
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:Panel runat="server" Title="Center">
                    <Items>
                        <ext:Container ID="ContainerOptions" runat="server" ClientIDMode="Static">
                            <Loader runat="server" Mode="Component" AutoLoad="false" DirectMethod="#{DirectMethods}.LoadOptionsUserControl">
                                <Params>
                                    <ext:Parameter Name="ReqType" Value="#{RequestTypesGroup}.getChecked()[0].inputValue"
                                        Mode="Raw" />
                                </Params>
                            </Loader>
                        </ext:Container>
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" Text="Description" OnDirectClick="ClickBuildDescription" />
                    </Buttons>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Options01.ascx
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
    
        // This is what I want to do, but not sure how to really access this."
        public String BuildDescription () {
    
            String description = "ABC";
            // Eventually there will be other controls in this ascx, but for now
            // just return the selected item.
            return description;
        }
    </script>
    <ext:FieldSet ID="FieldSetOptions" runat="server" ClientIDMode="Static" Title="Options" Collapsible="true">
        <Items>
            <ext:ComboBox runat="server" FieldLabel="Option01 Types" AllowBlank="false" Editable="false"
                IndicatorIcon="BulletRed">
                <Items>
                    <ext:ListItem Value="F" Text="Full" />
                    <ext:ListItem Value="P" Text="Partial" />
                </Items>
            </ext:ComboBox>
        </Items>
    </ext:FieldSet>
    Options02.ascx
    <%@ Control Language="C#"%>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        // This is what I want to do, but not sure how to really access this."
        public String BuildDescription()
        {
            String description = "XYZ";
            // Eventually there will be other controls in this ascx, but for now
            // just return the selected item.
            return description;
        }
    </script>
    <ext:FieldSet ID="FieldSetOptions" runat="server" ClientIDMode="Static"  Title="Options" Collapsible="true">
        <Items>
            <ext:ComboBox runat="server" FieldLabel="Option02 Types" AllowBlank="false" Editable="false"
                IndicatorIcon="BulletRed">
                <Items>
                    <ext:ListItem Value="One" Text="One" />
                    <ext:ListItem Value="Two" Text="Two" />
                    <ext:ListItem Value="Both" Text="Both" />
                </Items>
            </ext:ComboBox>
        </Items>
    </ext:FieldSet>
    Last edited by Daniil; Apr 30, 2013 at 4:13 AM. Reason: [CLOSED]

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2013, 6:00 PM
  2. Replies: 4
    Last Post: Dec 19, 2012, 9:58 AM
  3. Replies: 8
    Last Post: Feb 15, 2012, 9:04 AM
  4. Replies: 0
    Last Post: Aug 03, 2011, 10:27 PM
  5. [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl
    By Patrick in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 25, 2010, 9:33 AM

Posting Permissions