[OPEN] [#1271] [3.3.0] Dynamic User Control Assigning Value to Radio in RadioGroup on Page_Load Issue

  1. #1

    [OPEN] [#1271] [3.3.0] Dynamic User Control Assigning Value to Radio in RadioGroup on Page_Load Issue

    Hi, I'm currently having issue with dynamic user control.

    For example, I have this aspx file:
    <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Button ID="Button_AdvancedSearch" runat="server" Text="Advanced Search" Icon="Find">
                <DirectEvents>
                    <Click OnEvent="Button_Click">
                        <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>
    
            <ext:Window ID="Window_AdvancedSearch" runat="server" Title="Advanced Search" Icon="Application" Width="475px"
                Constrain="true" AutoHeight="true" BodyStyle="background-color: #fff;" Padding="5" Collapsible="true"
                Modal="false" Hidden="true" Resizable="false" Draggable="false" InitCenter="false"  >
            </ext:Window>
        </form>
    and this User Control:
    <ext:Radio ID="Radio_Test" runat="server" BoxLabel="Test 1" EnableViewState="false"></ext:Radio>
    <ext:RadioGroup ID="Radio_Group" runat="server">
        <Items>
            <ext:Radio ID="Radio_Option_1" runat="server" BoxLabel="Option 1" EnableViewState="false"></ext:Radio>
            <ext:Radio ID="Radio_Option_2" runat="server" BoxLabel="Option 2" EnableViewState="false"></ext:Radio>
        </Items>
    </ext:RadioGroup>
    Now the problem is in the aspx, upon clicking the button, I'm trying to load the user control into the window and show it.
    protected void Button_Click(object sender, Ext.Net.DirectEventArgs e)
            {
                WebUserControl1 webUserControl1 = (WebUserControl1)this.LoadControl("WebUserControl1.ascx");
                Window_AdvancedSearch.ContentControls.Add(webUserControl1);            
                Window_AdvancedSearch.UpdateContent();
    
                this.Window_AdvancedSearch.Show();
            }
    In the user control, on page load I setup the default value:
    protected void Page_Load(object sender, EventArgs e)
            {
                this.Radio_Test.Checked = true;
                this.Radio_Option_1.Value = true;            
            }
    When I run this and click on the button, javascript error was found : Cannot read property 'setValue' of undefined.
    I checked the json response from the ext.net was like this:
    Ext.suspendLayouts();
    App.Window_AdvancedSearch.removeAll();
    App.ctl07_Radio_Option_1.setValue(true);
    Ext.resumeLayouts(true);
    Ext.create("Ext.form.field.Radio",
    {"id":"idd1f898709eaf74fa_Radio_Test","
    	renderTo":"App.idd1f898709eaf74fa_Radio_Test_Container",
    	"value":false,
    	"boxLabel":"Test 1",
    	"inputValue":"App.idd1f898709eaf74fa_Radio_Test"
    });
    ...
    Seems like the setValue was called before the Radio control creation.

    However, this issue doesn't happen when I switch to Ext.NET 1.3 or 1.7

    I'm currently doing an upgrade from using Ext.NET 1.3 to Ext.NET 3.3.
    I'm not sure if this behavior is expected from the newer version,
    but if it is, kindly help how to make it run as it used to.

    Thanks.
  2. #2
    Hello @Cipta! And welcome to Ext.NET forums!

    Thank you for reporting the issue. I believe this is really a bug in the way the scripts are handled for the radio component when used under an user control and logged it into issue #1271!

    On the logged issue I've added a runnable example reproducing the issue (it was not very straightforward to run the test case the way you provided it, so take some time to look on how we usually share test cases here for faster responses!).

    In the test case I've added a textfield component which behaves nicely in the same situation where the radio checkboxes fail.

    We'll update here as soon as we fix this issue.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    The problem is related to the Issue #251 and it is difficult to find a generic fix.


    As a workaround, setting the Radio's .IsDynamic to true might help.

    <ext:Radio runat="server" IsDynamic="true" />
    IsDynamic should be only set to true if a Radio is meant to be rendered on the fly, as it is in your scenario.

    Here is another workaround - set a Radio's value via .CustomConfig().
    http://forums.ext.net/showthread.php...l=1#post105314

Similar Threads

  1. Replies: 1
    Last Post: Jan 26, 2015, 3:42 PM
  2. [CLOSED] Show User Control during Page_Load
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Oct 16, 2014, 2:54 PM
  3. [CLOSED] User Control Render dynamic value assign issue in page load
    By shaileshsakaria in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 26, 2014, 5:19 PM
  4. Replies: 9
    Last Post: Dec 07, 2012, 11:42 AM
  5. Replies: 4
    Last Post: Sep 25, 2012, 9:20 AM

Posting Permissions