telerik.web.mvc unable to load on visual studio 2013 - asp.net-mvc

I used to use visual studio 2012 and in an area telerik was configured and worked correctly.
after changing visual studio to 2013 this error occurred after each page is rendering.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Line 50: #(Html.Telerik().StyleSheetRegistrar())
web.config structure for this area view is:
<system.web.webPages.razor>
</system.web.webPages.razor>
i don't wanna change telerik to kendo.ui
what's the problem?

web.config of the view
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
<add namespace="Bazidan.MVC.UI" />
<add namespace="Telerik.Web.Mvc.UI"/>
<add namespace="MvcSiteMapProvider.Web.Html" />
<add namespace="MvcSiteMapProvider.Web.Html.Models" />
</namespaces>

Related

Problems with Resharper? VS 2015 and MVC

I got VS 2015 and MVC, i get this red stuff in several projects. What can be the cause. Views is the only problem, works fine in code behind.
add below in web.config(Inside View folder web.config as well outside web.config)
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
</namespaces>

MVC Helper #Html.LabelFor not showing up?

Am I missing a reference or something?
I have a reference to System.Web.Mvc 4.0x
But whenever I try this
#Html.LabelFor(x=>Model.yadda, new {id="_lblYadda"});
I get nothing I can't even get it to compile. I only have a reference to
#Html.Label("Yadda", "Yadda yadda");
I spent like 5 minutes looking, I know it's simple so.. help please!
WebConfig namespaces are:
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
Found my issue:
I noticed that the project that works references System.Web.Mvc.Html and the one that I'm using for #Html.Label() references System.Web.WebPages.dll
I removed the reference to System.Web.WebPages.dll and now it works with all the extensions.
System.Web.WebPages.dll is crap... The End... THanks

When extending HtmlHelper can't get intellisense to work without a using statment

I have extended HtmlHelper, then when trying to use it in partial view it doesn't show in intellisense, I have added the namespace to the web.config. the only way to get it to work was to add a using statement to the partial view. Am I missing something? I would prefer not to add using statements to every view using it.
Ensure that you are editing the config file in your Views directory.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Your.Namespace.Goes.Here" />
</namespaces>
</pages>
</system.web.webPages.razor>
Also, sometimes you might need to close and reopen the .cshtml file or even restart Visual Studio.

How do you implement a #using across all Views in Asp.Net MVC 3?

All I want to do is include this:
#using MyProject.WebUI.Properties
Across all my views without having to type it in each View, is there a way to do that in the ViewStart or Web.Config? Thank you.
Add your namespace to the views web.config under the namespaces element:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="MyProject.WebUI.Properties" />
</namespaces>
</pages>
</system.web.webPages.razor>
Note that you might have to close and reopen the view file that you want intellisense in for these changes to take affect.

Convert existing asp.net web application to MVC3

I have an existing asp.net web application which I need to convert to mvc3.
As soon as I add the below my project's web.config, the project stops working I am using IIS 5. I guess I have missed something in IIS, please advise
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
First confirm if any MVC3 project works with IIS5 the way you have it configured, you may need to setup the wildcard rule and uncheck verify if file exsists. Once you have done this what I do is just create a new MVC3 project that is empty and move over my stuff from the old project to the new project. That is the least hassel free way of doing it. Keep the namespace of the solution the same so you don't have to deal with namespace mismatch issues.

Resources