Kendo UI throwing CS1593: Delegate 'System.Action' does not take 1 arguments - asp.net-mvc

Here is a block of code that was working and now isn't. I am using Kendo UI for MVC. The error is
CS1593: Delegate 'System.Action' does not take 1 arguments.
This was an older site; opening and running shows the working version as VS2010, I did update Kendo and MVC, but not in this project. Any ideas?
#(Html.Kendo().Window()
.Name("Window")
.Title("Results")
.Content(#<text><div class="Result"></div></text>).Draggable()
.Resizable()
.Visible(false)
.Width(450)
.Actions(actions => actions.Minimize().Maximize().Close())
)

I found the answer.
I had updated from MVC3 to MVC4
This update will break 3 party controls
please read this section of release notes
http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815
section: Installing ASP.NET MVC 4 breaks ASP.NET MVC 3 RTM applications.
Item 3 in this section was all that wasn't there. Once corrected, everything works fine.

In case this is of use to someone else I found that
CS1593: Delegate 'System.Action' does not take 1 arguments.
is potentially a bit of a 'catch all' for errors in the function passed to the Content method.
In my case I was using a Kendo.Mvc.UI.Fluent.SplitterPanBuilder (which has a method signature of public SplitterPaneBuilder Content(Func<object, object> content);) and the error came from where I had changed the namespace of a class used and not updated it.
To better illustrate this here is some (pseudo-ish) code which caused the error
verticalPanes.Add()
.Content
(
#<div class="pane-content" id=#panelName>
#(Html.Kendo().Grid<OldInvalidNameSpace.Person>().Name(reportGridName))
</div>
)
and changing to this:
verticalPanes.Add()
.Content
(
#<div class="pane-content" id=#panelName>
#(Html.Kendo().Grid<NewValidNameSpace.Person>().Name(reportGridName))
</div>
)
resolved it.
In my mind the error does really help pinpoint the cause, but maybe knowing this will help someone else!

For me the problem was that I used a model item inside Content() that wasn't present in the model. That also triggered CS1593 error.

Related

KendoUI Autocomplete list appears on top of the textbox

I am making my first steps with KendoUI for MVC. I have a very simple model that reads a table "Products" from the database and passes it to the view as a strongly type model.
I am using the Model to bind it to the autocomplete to get the suggested values. This works almost fine. This is done using the following Razor syntax:
#(Html.Kendo().AutoComplete()
.Name("productAutoComplete")
.DataTextField("Name")
.BindTo(Model)
.Filter(FilterType.StartsWith)
.Placeholder("Select the product")
.Suggest(true)
)
The problem that I have is that the dropdown list that has the suggestions for the autocomplete appears on top of the textbox itself (instead of right below it).
Please see the image below without typing anything in the autocomplete field:
And with the autocomplete in action:
Do you have any suggestions?
Thanks in advance,
Lefteris
I have overcome the problem by using the latest jQuery library (1.9.1) instead of the one shipped with KendoUI (1.7.1).
I am still not sure why this was not working with 1.7.1 (it is ok with 1.9.0+).
In any case KendoUI latest version (Q1 2013) ships with 1.9.1 jQuery. Unfortunatelly this doesn't seem to be available yes as a trial for KendoUI Complete for ASP.NET MVC
I hope this solution helps someone else.
Lefteris

String.format help needed with mvc 3 razor (vb.net) please?

I've inherited some code... and am trying to convert it to use MVC 3, with Razor, the VBHTML is as follows:
For Each Message As MessageDetailsModel In Model.Messages
#<div id='#Message.HeaderId' class='#Message.HeaderCss' onclick=#(String.Format("shMsgTree('{0}','{1}',{2},'{3}');", Message.HeaderCss, Message.HeaderId, Message.MessageId, Message.UserId))>
... more stuff...
</div>
Next
Stepping through the code, the String.format resolves to this:
shMsgTree('sh_msg_GridItem sh_msg_MessageRead ','divHeader0',40,'{85A433F0-4054-42E7-B778-3EF005E411D3}');
which is what I want on the page, but for some reason, it gets output on the page as this:
shMsgTree('sh_msg_GridAltItem" sh_msg_MessageRead="
The properties on the model are all strings.
Am at a bit of a loss as to how to get it to render. Originally the entire onclick javascript was being returned in the Model, but that didn't render any better either.
Any suggestions would really be welcome. Thanks!
Given our conversation in the comments and the fact that the original Razor is quite hard to read, I think I'd recommend either:
writing a Razor Helper for this small block of code http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx
or writing a normal Extension Method to output the code - http://weblogs.asp.net/jgalloway/archive/2011/03/23/comparing-mvc-3-helpers-using-extension-methods-and-declarative-razor-helper.aspx (this is what I would choose!)
Without stepping through it in code, it's too hard to read the syntax as currently written - so break it out into a separate compact, testable, readable component.
Hope that helps
Stuart
Not sure if this will do it, but your onClickcode needs to be wrapped in quotes, before and after: onClick="#(String.Format(...))"

MvcContrib FluentHtml With Razor?

I'm wondering does the latest release of MvcContrib work with the Razor view engine? I referenced the MvcContrib assembly and the FluentHtml assembly, then I added the required namespace to the ~/View/Web.config as suggested here by Darin. But still, no matter how much I try use the FluentHtml extensions in my views, it doesn't work. (nothing shows up in intellisense when I start with a dot after the html helper)
Am I missing anything?
P.S: this is the first time I use MvcContrib.
I wrote a short blog that post covers using FluentHtml with Razor.
Regarding intellisense, you will only get intellisense for FluentHtml methods on "#this." (not "#Html.") and it only list the strong-typed helpers on views that implement IViewModelContainer<T> (such as ModelWebViewPage<T>). Another possible issue is Resharper. There is a workaround for that.
I´m using mvccontrib and following darin answer it has to work. The steps I followed were:
copy-pasted in bin folder mvccontrib.dll and mvccontrib.fluent.dll
make a reference in references to those dll creating a reference for mvccontrib and mvccontrib.fluent.
two namespaces with the following names:
add namespace="MvcContrib"
add namespace="MvcContrib.FluentHtml"
in my controller I include using MvcContrib.Pagination;
finally I used in my view:
#using MvcContrib.UI.Pager
#using MvcContrib.Pagination
and rebuild.
hope it helps..

Html.RenderAction<MyController> - does not have type parameters

I'm trying to use RenderAction in the following way:
'<% Html.RenderAction( x => x.ControllerAction() ); %>'
as seen here:
http://devlicio.us/blogs/derik_whittaker/archive/2008/11/24/renderpartial-vs-renderaction.aspx
and here:
http://eduncan911.com/blog/html-renderaction-for-asp-net-mvc-1-0.aspx
but I keep getting an error about the method not having type parameters. also in MSDN I see there is no documentation for it, and also checking the MVC source code I can't find anything.
I'm using the latest ASP.Net MVC (2.0 RTM)
is this feature no longer available? how can I use it?
thanks.
There are no Html.RenderAction overload which accepts an expression in the ASP.Net MVC 2 RTM. So no, it's not available.

Parse Error ViewMasterPage<TModel>

I am trying to implement a strongly typed master page and using this page as an example:
How to create a strongly typed master page using a base controller in ASP.NET MVC
I have the following declaration in my masterpage:
<%# Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<InsTech.ForeSight.Web.Mvc.ModelBase>" %>
When I try to run I get:
Parser Error Message: Could not load type 'System.Web.Mvc.ViewMasterPage<InsTech.ForeSight.Web.Mvc.ModelBase>'
I am not really sure why it can't find the type. When I use the ViewMasterPage class everything is okay, but when I try to use the generic version it bombs.
Any Suggestions
Is InsTech.ForeSight.Web.Mvc.ModelBase in another assembly? if so, is it referenced?
Is InsTech.ForeSight.Web.Mvc.ModelBase abstract?
I got this error when my MVC Master page was outside the 'Views' folder (with my normal Web forms master pages), moving it there solved this error for me.
Edit: Sorry I didn't see #Whoiskb already posted the same answer in the comments up there. Just leaving this answer for people who don't read all the comments :)

Resources