Telerik problems with IntelliSense and Templates - asp.net-mvc-3

I am working on the project where I use Telerik MVC controls in order to show some NumericTextBoxes and other controls. I have two problems that are maybe related.
1/ IntelliSense works fine in Views/Shared and in some Views. But in some it doesn´t work. The code is absolutely similar without specific blocks of code. I try to add all Telerik namespaces to Web.Config in Views folder, but it doesn´t work. Just in Views/Shared is IntelliSense working.
2/ I would like to use [SourceCodeFile] attribute in my Controller in order to using NumericTextBoxes templates. But VS says "Unknown attribute" and "Resolve" is not in context menu. I was trying to add all Telerik namespaces but it still doesn´t work.
Some suggestions?

Related

MVC 5 Razor view displays Linq errors but page renders correctly

I frequently get errors such as displayed in the picture below when using Linq in a Razor view. I have obviously added the #using System.Linq include on the top of the page (although it will strangely work without it), but still get the errors no matter what i try.
Is there any way to prevent these errors from appearing? I know i shouldn't be using too much code inside a view, perhaps the best solution would be to build the list in the code, use it here and stop worrying about editor syntax errors?
Razor Linq Error
This kind of problems is often in some way related to the config files. Have you seen this answer?
The type 'IEnumerable<>' is defined in an assembly that is not referenced
You can also try to create a test project and see if everything works as expected there and if it does, compare the web config files for possible differences... Note that there are two of those in each mvc project...

Dev Express MVC Extensions with Razor - Controls Show as Lists

Any DevExpress control I use, just renders a list. I’ve tried all 3 possible syntaxes (listed on the site below) and every time, the control I want to use (TreeView, NavBar, etc.) just renders as a bulleted list. Any ideas why? I’ve checked Google and the DevExpress support center, but I can’t find any issues like this.
DevExpress with razor guide: http://documentation.devexpress.com/#AspNet/CustomDocument9944
I just put this code on my index page to test that DevExpress is working:
#{Html.DevExpress().NavBar(settings => {
settings.Name = "myNavBar";
settings.Groups.Add("Group1").Items.Add("Item1-1");
settings.Groups.Add("Group2").Items.Add("Item2-1");
settings.Groups.FindByText("Group2").Expanded = false;
}).Render();}
When it reaches the page, it just shows a bulleted list:
Group1
Item1-1
Group2
Any ideas what's causing this?
The project I was working on was being rendered inside another project. I just needed to get rid of my project's layout and add using statements to the cshtml pages:
#using DevExpress.Web.Mvc.UI;
#using DevExpress.Web.Mvc;
The only problem I still have, is the scriptlet code gets highlighted red (but it builds/works fine and has intellisense).
It seems that any required DevExpress' entry is not registered within the MasterPage (_Layout.cshtml) / Web.config http://help.devexpress.com/#AspNet/CustomDocument8163. I suggest that you use specially designed Visual Studio Project Templates http://help.devexpress.com/#AspNet/CustomDocument9145 to avoid missing any required DevExpress' entry.

Single Action Controllers and ReSharper's Solution-Wide Analysis

We've got an ASP.NET MVC 3 project that uses single action controllers, and ReSharper doesn't like it. For example:
#using (Html.BeginForm("DoRegister", "Account")) {
It doesn't like either DoRegister or Account, because it's looking for a class AccountController with an action DoRegister. What we've actually got is a folder Controllers\Account, with a single-action class DoRegister.
Can I teach ReSharper about this? If not, can I get it to ignore this particular pattern?
I know that I can right-click and Ignore Errors in the Errors in Solution window, but this only lasts until I pull an updated version of the code from source control, which gets annoying quite quickly.
I am afraid ReSharper supports only default MVC convention.
But you can disable MVC analysis:
At All
ReSharper->Options->ASP.NET->Other->Enable ASP.NET MVC references
On all unknown action and controller errors
Alt+Enter on error, Inspection Options for "Unknown Symbol"
At that specific place
Again, Alt+Enter on error, Supress Inspection "Unknown Symbol" with comment.

extending #Html.DropDownList mvc3

In my continuing effort to build out my form validation controls, I've gotten to the dropdownlist control and ran into a snag when I tried to customize this one.
I've tried using the TagBuilder and a simple String in extension methods to extend this control but when I try to "bind" it to a list on the back end, it's not actually binding any data to my dropdownlist. I'm sure I'm missing something (IEnumerable or the like) on my custom control but I have no idea what....any suggestions (code samples would be terrific) would be awesome.
thanks
You can go through the ASP.NET MVC source and get an idea as to how it is implemented.
Go through the License as well!!

Is there a way to prevent Visual Studio 2010 formatting C# code in ASP.NET MVC views?

I'd like Visual Studio to continue automatically formatting my .cs files, but is there a way to prevent it auto-formatting C# code in between the <% %> tags in ASP.NET MVC views because it really makes a mess of it?
As far as I know there isn't a way to turn off the formatting just in ASP.NET files as it uses the rules for C# in Tools -> Options -> Text Editor -> C#.
There is no way to do it and it is a huge time waster fixing up the formatting in .aspx pages over and over again. It drives me nuts.
There are two connect issues/bugs for this. One was marked as fixed for months but the latest response does not look like anything was even done.
https://connect.microsoft.com/VisualStudio/feedback/details/514691/add-aspx-or-inline-c-as-an-option-in-text-editor-formatting-options
https://connect.microsoft.com/VisualStudio/feedback/details/586729/support-c-formatting-options-for-aspx-pages
Unfortunately (afaik), you can't have separate settings for C# in .cs and .aspx files. You can change the settings for C# in Tools -> Options -> C# -> Formatting.
To get things to work well with MVC, I changed some settings in the New Lines section. I unchecked the boxes for control block, object initializers, and "else". This produces the walk-like-an-egyptian style braces that works best in MVC code, without screwing too much with my normal C# code. I leave the settings for functions, classes etc. alone since you don't normally define those in an .aspx file.
You may consider using Razor as your View Engine instead of aspx.
see also:
http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx (Scott Guthrie)
ASP.NET MVC Razor view engine (StackOverflow)

Resources