This is a migrated thread and some comments may be shown as answers.

[Solved] "Index was out of range"

4 Answers 127 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 04 Nov 2009, 06:23 PM
Hello,

what should be added to Visual Studio project to make extensions working? For quick test I've added reference to library and added two helpers (DictionaryExtensions.cs and HtmlHelperExtensions.cs) but when I try to open page I'm getting error:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


in this lines:
Line 168:            </div> 
Line 169:        </div> 
Line 170: <% Html.Telerik().Menu() 
Line 171:            .Name("Menu") 
Line 172:            .HtmlAttributes(new { style = "z-index: 3; position: relative;" }) 

My menu source:
        <% Html.Telerik().Menu() 
            .Name("Menu"
            .HtmlAttributes(new { style = "z-index: 3; position: relative;" }) 
            .Items(menu => 
            { 
                menu.Add() 
                    .Text("ASP.NET MVC"
                    .Items(item => 
                    { 
                        item.Add().Text("Grid"); 
                    }); 
            }) 
            .Render(); 
        %>  
I've added to controller "ViewData["expandMode"] = "Single";" too but nothing changed.
Any ideas?

Thanks


4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Nov 2009, 09:27 AM
Hello,

Please review this online help article which describes how to yse Telerik Extensions for ASP.NET MVC in your site. You can also review this online demo.

All the best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
GrZeCh
Top achievements
Rank 2
answered on 05 Nov 2009, 07:40 PM
After adding script registration:

<%  
    Html.Telerik().StyleSheetRegistrar() 
        .DefaultGroup(group => group.Add("telerik.common.css"
                                    .Add("telerik.vista.css")) 
        .Render();  
%> 

I'm getting this error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). 

If I remove script registration I'm getting error mentioned on the first post ("Index was out of range....").
0
Georgi Krustev
Telerik team
answered on 06 Nov 2009, 09:29 AM
Hello,

Unfortunately it is difficult to determine the cause of the error. Could you please send us entire view and the Site.master page. Thus we will review it and advice you further.

Sincerely yours,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
GrZeCh
Top achievements
Rank 2
answered on 19 Nov 2009, 02:22 PM
Hello,

I've changed in web.config:

    <runtime> 
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
            <dependentAssembly> 
                <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" /> 
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /> 
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" /> 
            </dependentAssembly> 
            <dependentAssembly xmlns=""
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
                <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" /> 
            </dependentAssembly> 
        </assemblyBinding> 
    </runtime> 

to
  <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
      <dependentAssembly> 
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> 
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> 
      </dependentAssembly> 
    </assemblyBinding> 
  </runtime> 

and it started working.


Tags
Menu
Asked by
GrZeCh
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
GrZeCh
Top achievements
Rank 2
Share this question
or