[CLOSED] Reference token (ctl07_ClientInit) was not found error. Why is it happening?

  1. #1

    [CLOSED] Reference token (ctl07_ClientInit) was not found error. Why is it happening?

    Code to reproduce:
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
    
      // This fails
      protected void Page_Load(object sender, EventArgs e)
      {
        List<string> items = new List<string>() {"Item 1", "Item 2", "Item 3"};
        IEnumerable<Ext.Net.MenuItem> menuItems = items.Select(o => new Ext.Net.MenuItem().ToBuilder().Text(o).ToComponent());
        Ext.Net.Menu menu = new Ext.Net.Menu().ToBuilder()
                    .Items(menuItems);
    
        this.myButton.Menu.Add(menu);
      }
      
      // This works
      protected void Page_Load2(object sender, EventArgs e)
      {
        List<string> items = new List<string>() { "Item 1", "Item 2", "Item 3" };
        Ext.Net.Menu menu = new Ext.Net.Menu();
    
        foreach (string item in items)
        {
          menu.Items.Add(new Ext.Net.MenuItem().ToBuilder().Text(item));
        }
        
                     
        this.myButton.Menu.Add(menu);
      }
      
      
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET Example</title>
        <link href="/resources/css/examples.css" rel="stylesheet" /> 
    
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button Text="Some Button" id="myButton" runat="server"/></ext:Button>
        </form>
    </body>
    </html>
    Last edited by Baidaly; Dec 13, 2013 at 7:50 PM. Reason: [CLOSED]
  2. #2
    Hello!

    Try to call ToList method:

    protected void Page_Load(object sender, EventArgs e)
    {
        List<string> items = new List<string>() {"Item 1", "Item 2", "Item 3"};
        IEnumerable<Ext.Net.MenuItem> menuItems = items.Select(o => new Ext.Net.MenuItem().ToBuilder().Text(o).ToComponent()).ToList(;
        Ext.Net.Menu menu = new Ext.Net.Menu().ToBuilder()
                    .Items(menuItems);
     
        this.myButton.Menu.Add(menu);
    }
  3. #3
    Why does it fail though when I pass an IEnumerable?
  4. #4
    As far as I can see (debugging) the Select method returns an instance of {System.Linq.Enumerable.WhereSelectListIterator<st ring,Ext.Net.MenuItem>}.

    It looks like the Items cannot apply such an argument. Honestly, I am not sure why it is not throwing an Exception at run time, at least.
  5. #5
    It's a common rule in .NET to cast LINQ expressions to List or other distinct type at the end of calculation otherwise it means that you want to continue calculation. Moreover, usually LINQ (LINQ to Objects particularly) uses lazy-calculation so in fact the collection can be empty.

    In this case, it's difficult to say, what causes this exception.

    We will close this thread but if you have any question feel free to post.

Similar Threads

  1. Replies: 13
    Last Post: Nov 22, 2013, 10:30 AM
  2. [CLOSED] Token is not unique error for nested grid
    By alscg in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 01, 2013, 4:53 AM
  3. [CLOSED] Reference token (ext.net.initscriptfiles) was not found.
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 14
    Last Post: Oct 08, 2013, 10:24 AM
  4. Replies: 5
    Last Post: Jun 11, 2013, 7:46 AM
  5. Replies: 4
    Last Post: Mar 30, 2012, 7:30 PM

Posting Permissions