[CLOSED] JScript compilation error: Syntax error (eval(result.script));

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] JScript compilation error: Syntax error (eval(result.script));

    Hello,
    I'm trying to add control dynamically and receive - Microsoft JScript runtime error: Expected ';'
    result.script:
    Ext.net.append(Ext.get('DefaultForm'),["    <script type=\"text/javascript\">","        var setInfo = function (values) {","            switch (values.user) {","                case 'Tommy Maintz':","                    {","                        return '1';","                        break;","                    }","                case 'Core Team':","                    {","                        return '2';","                        break;","                    }","                default:","                    {","                        return '3';","                    }","            };","        };","    <\/script>","    <script type=\"text/javascript\">","        var setInfo = function (values) {","            switch (values.user) {","                case 'Tommy Maintz':","                    {","                        return '1';","                        break;","                    }","                case 'Core Team':","                    {","                        return '2';","                        break;","                    }","                default:","                    {","                        return '3';","                    }","            };","        };","    <\/script>","    <script type=\"text/javascript\">","        var setInfo = function (values) {","            switch (values.user) {","                case 'Tommy Maintz':","                    {","                        return '1';","                        break;","                    }","                case 'Core Team':","                    {","                        return '2';","                        break;","                    }","                default:","                    {","                        return '3';","                    }","            };","        };","    <\/script>"].join(''));Ext.net.ResourceMgr.registerIcon(["Folder","Page","ApplicationCascade","BulletPlus","PageDelete","Package","FolderUser","PageError","PageEdit","FolderDelete","FolderEdit","PageCopy"]);ProjectDocuments1_ContactSelector1_ContactBook1_ContactBook1_txtIsContactSelector.setValue("1");ContactSelector1_ContactBook1_ContactBook1_txtIsContactSelector.setValue("1");{id:"ProjectDocuments1_cartItemsNGControl_Container1",xtype:"container",items:[{id:"ProjectDocuments1_cartItemsNGControl_tpCartItems",xtype:"nettreepanel",columnWidth:0.25,autoScroll:true,rootVisible:false,useArrows:true,nodes:[{text:"Cart Items"}]},{id:"ProjectDocuments1_cartItemsNGControl_tgDistribution",xtype:"treegrid",columnWidth:0.5,enableDD:true,nodes:[{text:"Cart Distribution"}],columns:[{dataIndex:"Name",header:"Name",width:230.0},{header:"Descpiption",tpl:this.ProjectDocuments1_cartItemsNGControl_XTemplate1=new Ext.net.XTemplate({proxyId:"ProjectDocuments1_cartItemsNGControl_XTemplate1",functions:{setInfo:setInfo},html:["{.:this.setInfo}",""]}),width:100.0}]},{id:"ProjectDocuments1_cartItemsNGControl_pgCommon",xtype:"netpropertygrid",columnWidth:0.25,autoScroll:true,selectionMemory:false,cm:this.ProjectDocuments1_cartItemsNGControl_id3a16d0ca70e643129dd31785c2eb8308=new Ext.grid.ColumnModel({proxyId:""}),editable:false}],layout:"netcolumn",layoutConfig:{split:true}}ProjectDocuments1_ShowpnlCheckOutContent.setValue("true");
    code which adding control:
     var cartItemsNgControl = (CartItemsNG)LoadControl("~/Planroom/UserControls/CartItemsNG.ascx");
                        cartItemsNgControl.ID = "cartItemsNGControl";
                        pnlCheckOutContent.ContentControls.Add(cartItemsNgControl);
                        pnlCheckOutContent.UpdateContent();
                        ShowpnlCheckOutContent.Text = @"true";
    parent code
    <ext:Window ID="winCheckout" Width="1100" Height="700" runat="server" Hidden="true"
        Layout="Fit">
        <Items>
            <ext:Container ID="pnlCheckOutContent" runat="server" />
        </Items>
         <Listeners>
            <BeforeShow Handler="setWindowSize1(this,90,90);this.center();; dirtyFlagCartItems = false;" />
        </Listeners>
        <DirectEvents>
            <BeforeShow OnEvent="ShowCheckOutContent">
                <EventMask ShowMask="true" />
            </BeforeShow>
            <BeforeHide OnEvent="HideCheckOutContent" />
        </DirectEvents>
        <Buttons>
            <ext:Button ID="btnCheckOutNext" Icon="NextGreen" runat="server" Disabled="true"
                meta:Resourcekey="NextResource1">
                <Listeners>
                    <%--<Click Handler="ShowPayment();" />--%>
                </Listeners>
            </ext:Button>
            <ext:Button ID="btnCheckOutPrev" Icon="PreviousGreen" runat="server" meta:resourcekey="PreviousResource1">
                <Listeners>
                    <%--<Click Handler="ShowCartItems();" />--%>
                </Listeners>
            </ext:Button>
            <ext:Button ID="btnPurchase" runat="server" Icon="CartGo" Disabled="true" meta:Resourcekey="PurchaseResource1">
                <Listeners>
                    <%--<Click Handler="CompletePurchase();" />--%>
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    user control CartItemsNG.ascx:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CartItemsNG.ascx.cs"
        Inherits="ABCImaging.BPOL.Main.Planroom.Planroom.UserControls.CartItemsNG" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:XScript runat="server">
        <script type="text/javascript">
            var setInfo = function (values) {
                switch (values.user) {
                    case 'Tommy Maintz':
                        {
                            return '1';
                            break;
                        }
                    case 'Core Team':
                        {
                            return '2';
                            break;
                        }
                    default:
                        {
                            return '3';
                        }
                };
            };
        </script>
    </ext:XScript>
    <ext:FitLayout runat="server" ID="reportLayout">
        <Items>
            <ext:Container ID="Container1" runat="server" Layout="Fit">
                <Items>
                    <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="true" FitHeight="true">
                        <Columns>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:TreePanel ID="tpCartItems" runat="server" Animate="true" UseArrows="true" RootVisible="false" AutoScroll="true">
                                    <Root>
                                        <ext:TreeNode Text="Cart Items" />
                                    </Root>
                                </ext:TreePanel>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.5">
                                <ext:TreeGrid ID="tgDistribution" runat="server" EnableDD="true" RootVisible="false">
                                    <Columns>
                                        <ext:TreeGridColumn Header="Name" Width="230" DataIndex="Name" />
                                        <ext:TreeGridColumn Width="100" Header="Descpiption">
                                            <XTemplate ID="XTemplate1" runat="server">
                                                <Html>
                                               {.:this.setInfo}
                                            </Html>
                                                <Functions>
                                                    <ext:JFunction Name="setInfo" Fn="setInfo" />
                                                </Functions>
                                            </XTemplate>
                                        </ext:TreeGridColumn>
                                    </Columns>
                                    <Root>
                                        <ext:TreeNode Text="Cart Distribution" />
                                    </Root>
                                </ext:TreeGrid>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:PropertyGrid ID="pgCommon" runat="server" AutoScroll="true"
                                    Editable="false">
                                    <Source>
                                    </Source>
                                </ext:PropertyGrid>
                            </ext:LayoutColumn>
                        </Columns>
                    </ext:ColumnLayout>
                </Items>
            </ext:Container>
        </Items>
    </ext:FitLayout>
    Last edited by Daniil; Oct 12, 2011 at 8:20 PM. Reason: [CLOSED]
  2. #2
    Hi,

    When a top level control in a user control is a layout control, please use .Render() instead of .UpdateContent().
  3. #3
    By the way, in this case the scrips won't be rendered. Please move it into containers Content.
  4. #4
    In another topic I have read that if I want to render JavaScripts with page I have to use updatecontent instead of render. Issue that I have to use a lot of scripts on this complex control which will be use data from the control and it will be almost impossible to move all of them to parent control and use id's like parentcontrol_usercontrol_control. Is there any way to add scripts to user control? I tryed to remove all scripts from usercontrol and it still showing same error when we do updatecontent.
  5. #5
    Repeat myself, please use .Render() and place the scrips into <Content> of any container.
  6. #6
    Ok, I did:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CartItemsNG.ascx.cs"
        Inherits="ABCImaging.BPOL.Main.Planroom.Planroom.UserControls.CartItemsNG" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Container>
        <ext:XScript runat="server">
            <script type="text/javascript">
                var setInfo = function (values) {
                    switch (values.user) {
                        case 'Tommy Maintz':
                            {
                                return '1';
                                break;
                            }
                        case 'Core Team':
                            {
                                return '2';
                                break;
                            }
                        default:
                            {
                                return '3';
                            }
                    };
                };
            </script>
        </ext:XScript>
    </ext:Container>
    <ext:FitLayout runat="server" ID="reportLayout">
        <Items>
            <ext:Container ID="Container1" runat="server" Layout="Fit">
                <Items>
                    <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="true" FitHeight="true">
                        <Columns>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:TreePanel ID="tpCartItems" runat="server" Animate="true" UseArrows="true" RootVisible="false"
                                    AutoScroll="true">
                                    <Root>
                                        <ext:TreeNode Text="Cart Items" />
                                    </Root>
                                </ext:TreePanel>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.5">
                                <ext:TreeGrid ID="tgDistribution" runat="server" EnableDD="true" RootVisible="false">
                                    <Columns>
                                        <ext:TreeGridColumn Header="Name" Width="230" DataIndex="Name" />
                                        <ext:TreeGridColumn Width="100" Header="Descpiption">
                                            <XTemplate ID="XTemplate1" runat="server">
                                                <Html>
                                               {.:this.setInfo}
                                            </Html>
                                                <Functions>
                                                    <ext:JFunction Name="setInfo" Fn="setInfo" />
                                                </Functions>
                                            </XTemplate>
                                        </ext:TreeGridColumn>
                                    </Columns>
                                    <Root>
                                        <ext:TreeNode Text="Cart Distribution" />
                                    </Root>
                                </ext:TreeGrid>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:PropertyGrid ID="pgCommon" runat="server" AutoScroll="true" Editable="false">
                                    <Source>
                                    </Source>
                                </ext:PropertyGrid>
                            </ext:LayoutColumn>
                        </Columns>
                    </ext:ColumnLayout>
                </Items>
            </ext:Container>
        </Items>
    </ext:FitLayout>
    Error: Microsoft JScript runtime error: 'setInfo' is undefined
  7. #7
    Sorry, forgot content
  8. #8
    Can we mark the thread as closed?
  9. #9
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CartItemsNG.ascx.cs"
        Inherits="ABCImaging.BPOL.Main.Planroom.Planroom.UserControls.CartItemsNG" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Container runat="server">
        <Content>
                <ext:XScript ID="XScript1" runat="server">
            <script type="text/javascript">
                var setInfo = function (values) {
                    switch (values.user) {
                        case 'Tommy Maintz':
                            {
                                return '1';
                                break;
                            }
                        case 'Core Team':
                            {
                                return '2';
                                break;
                            }
                        default:
                            {
                                return '3';
                            }
                    };
                };
            </script>
        </ext:XScript>
        </Content>
    </ext:Container>
    <ext:FitLayout runat="server" ID="reportLayout">
        <Items>
            <ext:Container ID="Container1" runat="server" Layout="Fit">
                <Items>
                    <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="true" FitHeight="true">
                        <Columns>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:TreePanel ID="tpCartItems" runat="server" Animate="true" UseArrows="true" RootVisible="false"
                                    AutoScroll="true">
                                    <Root>
                                        <ext:TreeNode Text="Cart Items" />
                                    </Root>
                                </ext:TreePanel>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.5">
                                <ext:TreeGrid ID="tgDistribution" runat="server" EnableDD="true" RootVisible="false">
                                    <Columns>
                                        <ext:TreeGridColumn Header="Name" Width="230" DataIndex="Name" />
                                        <ext:TreeGridColumn Width="100" Header="Descpiption">
                                            <XTemplate ID="XTemplate1" runat="server">
                                                <Html>
                                               {.:this.setInfo}
                                            </Html>
                                                <Functions>
                                                    <ext:JFunction Name="setInfo" Fn="setInfo" />
                                                </Functions>
                                            </XTemplate>
                                        </ext:TreeGridColumn>
                                    </Columns>
                                    <Root>
                                        <ext:TreeNode Text="Cart Distribution" />
                                    </Root>
                                </ext:TreeGrid>
                            </ext:LayoutColumn>
                            <ext:LayoutColumn ColumnWidth="0.25">
                                <ext:PropertyGrid ID="pgCommon" runat="server" AutoScroll="true" Editable="false">
                                    <Source>
                                    </Source>
                                </ext:PropertyGrid>
                            </ext:LayoutColumn>
                        </Columns>
                    </ext:ColumnLayout>
                </Items>
            </ext:Container>
        </Items>
    </ext:FitLayout>
    Error: Microsoft JScript runtime error: 'setInfo' is undefined
  10. #10
    Please place the script into Content of Container1.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Aug 09, 2012, 2:27 PM
  2. Replies: 2
    Last Post: Nov 05, 2011, 8:52 AM
  3. Replies: 4
    Last Post: Jan 25, 2011, 11:39 AM
  4. Replies: 2
    Last Post: Jul 29, 2009, 2:57 PM
  5. [CLOSED] AjaxMethod Error = BADRESPONSE: Syntax error
    By randy85253 in forum 1.x Premium Help
    Replies: 2
    Last Post: Dec 05, 2008, 7:37 PM

Posting Permissions