[1.0] JavaScript error on load user control

  1. #1

    [1.0] JavaScript error on load user control

    Hi,
    I am trying to load a user control with dynamic select boxes at runtime.
    I get following message: "Microsoft JScript compilation error: Expected ':' "

    Here is my scenario

    main page

    <ext:Panel ID="Panel1" runat="server">
                <Content>
                    <table width="100%" height="100%">
                        <tr>
                            <td>
                                <ext:SelectBox AutoDataBind="true" ID="TechDescrSB" runat="server" StoreID="TechDescrStore"
                                    ValueField="DescrId" DisplayField="Descr" FieldLabel="Тех. характеристика (модель)"
                                    Width="400">
                                    <DirectEvents>
                                    <Select OnEvent="CreateCtrl">
                                            <ExtraParams>
                                                <ext:Parameter Name="DescrId" Value="#{TechDescrSB}.getValue()" Mode="Raw" />
                                            </ExtraParams>
                                        </Select>
                                    </DirectEvents>
                                </ext:SelectBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                            <ext:Container ID="Container1" runat="server" Region="Center" Layout="Fit"> 
                                <Items>
                                    <ext:Panel runat="server" ID="DynPan1" Height="25"></ext:Panel>
                                </Items>
                            </ext:Container>
                            
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
    Codebehind main page

    protected void CreateCtrl(object sender, DirectEventArgs e)
            {
                var control = LoadControl("UserControls/CreateATDControls.ascx");
                DynPan1.ContentControls.Add(control);
                DynPan1.UpdateContent();
            }
    User Control

    <ext:Panel runat="server" ID="DynPan" AutoHeight="true">
    <Content>
    <ext:Store ID="UCStore" runat="server" >         
        <Reader>       
            <ext:JsonReader root="data">
                <Fields>
                    <ext:RecordField Name="AdvTechDescrSprId" Type="Int" />
                    <ext:RecordField Name="DescrId" Type="Int" />
                    <ext:RecordField Name="AdvTechDescrNameSprId" Type="Int" />
                    <ext:RecordField Name="Value" Type="String" />
                    <ext:RecordField Name="IsDefault" Type="Boolean" />
                </Fields>
            </ext:JsonReader>
        </Reader>        
    </ext:Store> 
    </Content>
    </ext:Panel>
    CodeBehind UserControl

     public int DescrId
            {
                get { return Request.QueryString["DescrId"] != null ? Convert.ToInt32(Request.QueryString["DescrId"]) : 27; }
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {            
                int i = 0;
                List<TAdvTechDescrNameSpr> l = new AdvTechDescrSprManager().GetUnqAdvTechDescrNameListByDescrID(DescrId);
                foreach (TAdvTechDescrNameSpr obj in l)
                {
                    i += 1;
                    string showName = obj.Name;
                    List<TAdvTechDescrSpr> atdList = new AdvTechDescrSprManager().GetAdvTechDescrList(DescrId, obj.AdvTechDescrNameSprId);               
                   
                        UCStore.DataSource = atdList;
                        UCStore.SetDataFromJson(String.Format("{{totalCount:{1},'data' : {0}}}", JSON.Serialize(atdList), atdList.Count));
                        UCStore.DataBind();
    
    
                        SelectBox sb = new SelectBox();
                        sb.StoreID = "UCStore";
                        sb.DisplayField = "Value";
                        sb.ValueField = "AdvTechDescrSprId";
                        sb.FieldLabel = showName;
                        sb.Width = Unit.Pixel(250);
                        sb.SelectedIndex = 0;
    
                        DynPan.Items.Add(sb);
                        DynPan.Render();               
                }
            }
    Printscreen with message attached
    Attached Thumbnails Click image for larger version. 

Name:	err.jpg 
Views:	104 
Size:	103.9 KB 
ID:	1632  
  2. #2
    Hi,

    Please remove
    DynPan.Render();
  3. #3
    After changes (remove render) I get the following message "ctl1`2_UCStore is undefined". What is wrong?
    Attached Thumbnails Click image for larger version. 

Name:	err.jpg 
Views:	115 
Size:	94.0 KB 
ID:	1633  
  4. #4
    Hi,

    Content is always rendered after Items. Therefore move the store outside the panel (before DynPan)
  5. #5
    It's work now! Thank you :cool:

Similar Threads

  1. Replies: 2
    Last Post: Feb 06, 2012, 9:06 AM
  2. [CLOSED] JavaScript error in dynamic user control
    By schellappa in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Dec 21, 2010, 4:01 PM
  3. how to load user control ondemand.
    By Satyanarayana murthy in forum 1.x Help
    Replies: 2
    Last Post: Jun 17, 2010, 7:40 AM
  4. [CLOSED] Programmatically load User Control from AJAXMethod
    By SamFoot in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 28, 2009, 4:47 AM
  5. Load user control on DesktopWindow open
    By Mohammad Yakub in forum 1.x Help
    Replies: 0
    Last Post: Jan 29, 2009, 8:49 AM

Posting Permissions