+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Server Error using JsFileLink

Server Error using JsFileLink

5 posts, 1 answered
  1. Donnie Hale
    Donnie Hale avatar
    13 posts
    Registered:
    28 May 2010
    03 Aug 2010
    Link to this post
    I'm trying to use a JsFileLink in my master pages so that I get correct path-relative locations for my .js files. When I do that, I get a server error - "Collection was modified; enumeration operation may not execute.". Here is the <head> element of my master page:

    <head id="Head1" runat="server">
        <title>Nations Health : Diabetic Supplies</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="TBD" />
     
        <link rel="stylesheet" runat="server" href="~/assets/css/reset.css" type="text/css" media="screen, projection"/>
        <link rel="stylesheet" runat="server" href="~/assets/css/styles.css" type="text/css" media="screen, projection"/>
     
        <link rel="shortcut icon" runat="server" href="~/assets/images/production/global/favicon.png"/>
        <link rel="apple-touch-icon" runat="server" href="~/assets/images/production/global/apple-touch-icon.png"/>
     
        <sf:JsFileLink id="jsPrototypeLink" runat="server" FileName="~/assets/js/prototype.js"></sf:JsFileLink>
        <sf:JsFileLink id="jsApplicationLink" runat="server" FileName="~/assets/js/application.js"></sf:JsFileLink>
     
        <asp:ContentPlaceHolder ID="headTag" runat="server">
        </asp:ContentPlaceHolder>
    </head>

    The full error page is:

    Collection was modified; enumeration operation may not execute.

    Server Error in '/nationshealth' Application.

    Collection was modified; enumeration operation may not execute.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidOperationException: Collection was modified; enumeration operation may not execute.]
       System.Web.UI.ControlCollectionEnumerator.MoveNext() +8651662
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(ControlCollection controls, Dictionary`2 list, IList`1 controlIds) +364
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(ControlCollection controls, Dictionary`2 list, IList`1 controlIds) +355
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(MasterPage master, IList`1 controlIds) +127
       Telerik.Cms.Web.InternalPage.CreateChildControls() +375
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3607; ASP.NET Version:2.0.50727.3614


    What am I doing wrong? This would be a terribly useful control for our application.

    Thanks,

    Donnie
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Aug 2010
    Link to this post
    Hi Donnie Hale,

    Thank you for using our services.

    The JsFileLink control should not be placed in the header tag of your master page. Could you please try putting it inside the form tag.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Donnie Hale
    Donnie Hale avatar
    13 posts
    Registered:
    28 May 2010
    04 Aug 2010
    Link to this post
    I've found a workaround, but not being able to place it in the <head> element sort of defeats the purpose. That's the canonical location for including javascript files. I understand it's probably an asp.net limitation.

    Donnie
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Aug 2010
    Link to this post
    Hello Donnie Hale,

    The JsFileLink inserts a <script> tag into your <head> pointing to the referenced java script file. You can inspect the produced markup to verify that the linked js file is in the markup.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Donnie Hale
    Donnie Hale avatar
    13 posts
    Registered:
    28 May 2010
    04 Aug 2010
    Link to this post
    Just to make sure I'm clear: I need to put the JsFileLink inside the form tag. But it renders the script element inside the head tag? While not intuitive, that would work.

    Thanks,

    Donnie
Register for webinar
5 posts, 1 answered