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

Strange error with menu binding.

2 Answers 136 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.
Juan Pablo Perez
Top achievements
Rank 1
Juan Pablo Perez asked on 16 Dec 2010, 08:29 AM
I have a project made with MVC3 RC with Razor and with Telerik's Menu and PanelBar controls (version 2010.3.1110.235). It was working well. I updated the project to MVC3 RC2 and everything still works properly. But after adding a new model class nothing works. I got the error:
 
CS1593: Delegate 'System.Action<Telerik.Web.Mvc.UI.MenuItem, LoyaltyCRM.Model.ModelAccess.tfnGetAllOptionsResult>' does not take 1 arguments.

I deleted the new class added and it still doesn't work. I recover a backup before adding the model class and it works but when I tried to create a new View and the Menu control doesn't recognize the former model.

Here is an example of the code that is working:

@model LoyaltyCRM.Model.ViewModels.Authorizations.ViewModelAuthorizedOptions
@using Telerik.Web.Mvc.UI
@using LoyaltyCRM.Model.ModelAccess
<br class="fclear" />
@(Html.Telerik().Menu()
        .Name("MainMenu")
        .BindTo(Model.Models, mapping => mapping
            .For<tfnGetAllAuthorizedMastersOptionsResult>(binding => binding
                .ItemDataBound((item, o) =>
                {
                    item.Visible = true;
                    if (o.Controller!=null)
                        item.ControllerName = o.Controller;
                    if (o.Action!=null)
                        item.ActionName = o.Action;
                    if (o.Url != null)
                        item.Url = (o.Url.StartsWith("/") ? "/" + Model.SessionVariables.User.Culture : "") + o.Url;
                    if (o.HtmlAttributes!=null)
                        item.HtmlAttributes.Add("Style", o.HtmlAttributes);
                    if (o.ImageUrl != null)
                    {
                        item.ImageUrl = o.ImageUrl;
                        if (o.Cultures_Alt != null)
                            item.ImageHtmlAttributes.Add("Alt", o.Cultures_Alt);

And here is the new code I try to create:
@model LoyaltyCRM.Model.ViewModels.Users.ViewModelOptions
@using Telerik.Web.Mvc.UI
@using LoyaltyCRM.Model.ModelAccess
<br class="fclear" />
@(Html.Telerik().Menu()
        .Name("MainMenu")
        .BindTo(Model.Models, mapping => mapping

When I press . after BindTo to see what IntelliSense gives the option for For<> does not appear, instead it shows the options of telerik menu item. In the original View when you press the . after BindTo IntelliSense shows Equals, For<>, GetHashCode, GetType and ToString.

I think BindTo is not considering the model Model.Models like an IEnumerable (I've declared it as IList) and that's is why is not working. The problem is that I don't know how to solve it.

Any suggestion?

Thanks in advance.

Juan Pablo

2 Answers, 1 is accepted

Sort by
0
Juan Pablo Perez
Top achievements
Rank 1
answered on 17 Dec 2010, 08:21 AM
I found the problem. There was a property in the list of options missing. It's been very difficult to find it. I think if you have an error like

CS1593: Delegate 'System.Action<Telerik.Web.Mvc.UI.MenuItem, LoyaltyCRM.Model.ModelAccess.tfnGetAllOptionsResult>' does not take 1 arguments.

is because of the model you are using is not correct. 

What I was explaining about IntelliSence I think is correct, because you have used the properties of the model it does not recognize it like a List (IEnumerable).

Juan Pablo
0
Chris
Top achievements
Rank 1
answered on 14 Apr 2011, 02:30 AM
I got this problem using the splitter. To troubleshoot, I began to comment out each block of content, using server-side comments, until the error went away (I was nearly down to the raw splitter implementation).

I started adding back little tiny bits until the error came back. I narrowed it down to this:
@foreach (var item in Model.SegmentMenu) {
}

For some reason, that was bombing it! Now, here's the crazy part. I put the offending code into a partial and just called the partial, in hopes that I would get a more meaningful error message. But instead of a more meaningful error message, IT WORKED.

I'm not a C# ninja and can barely wrap my head around delegates, so my apologies to anyone who would argue that the error error CS1593: Delegate 'System.Action' does not take 1 arguments actually does make sense :) If someone could explain to me why that code is illegal in the splitter content, but legal if called in the content with a partial, I would love to know!
Tags
Menu
Asked by
Juan Pablo Perez
Top achievements
Rank 1
Answers by
Juan Pablo Perez
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Share this question
or