.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links


Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery


I am a newbie in MVC3 asp.net  and my tag @Html.EditorFor(model => model.CategoryName, new { @class = "editor-field" }).

doesn't change the class of my textbox it appears the original. <input class="text-box single-line" id="CategoryName" name="CategoryName" type="text" value="" />

It does not change to my defined class which is editor-field.


Please help, no idea.

View Complete Post

More Related Resource Links

Problem upgrading to MVC3 - System.Web.Routing



I'm trying to upgrade to .NET 4 and MVC 3.

When trying to compile my project, I get the error:

Error 1 The type or namespace name 'Routing' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) C:\Users\spencer\Desktop\weblauncher\Common\MVCConfig.cs 4 18 Common

The type or namespace name 'Routing' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I do have the System.Web.Routing in my references for the project.

BUT - when I try to view System.Web.Routing in the OBJECT BROWSER, nothing is inside!  The System.Web.Routing namespace is not in there - the entire thing is empty!  Could it that the dll is corrupted?  I tried to reinstall the .NET 4 and MVC 3 stuff, but its still empty!

The dll is coming from here:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Routing.dll

and the runti

Will MVC3 make possible to use IOC with Action Filters



Will MVC3 make possible to use IOC with Action Filters?

Is this on the roadmap?



MVC3: Define Dynamic ViewModel property inside Action Filter



How can I define a Dynamic ViewModel property in MVC 3 inside an action filter?

I am looking to have something like but inside the ActionFilter and not in the controller:

ViewModel.Title = "Home";

Thank You,


ASP.NET MVC3 Areas and Razor views produce errors?


The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List. It does nothing except:

public ActionResult Index()
    return View("~/Areas/SomeArea/Views/List/Index.cshtml");

The view looks like:

@inherits System.Web.Mvc.WebViewPage<dynamic>
    View.Title = "Index";
    LayoutPage = "~/Views/Shared/_Layout.cshtml";


I have tried emptying the entire file part by part and nothing seems to help. If I create a controller and view outside the area it works just fine. If I create an aspx view it works fine as well. Is it possible the default razor view engine doesn't support areas at this time?

The areas are registered too.

public static void RegisterRoutes(RouteCollection routes)
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters

July preview of POP Forums v9 for ASP.NET MVC3 posted to CodePlex

Here it is, the third preview release of POP Forums v9. It's starting to smell like a real application now. New since the last release: Text parsing of HTML and "forum code" Dropped in TinyMCE text editor (still needs some customization and option for plain text) Security logging User profiled editing, for the users and admins, including avatar and photo uploads Admin pages for most of the forum settings, including category and forum management E-mail confirmation for new accounts, with verification mechanism View counting Runs on ASP.NET MVC3 (see notes below) Lots o' refactoring and more unit tests (now over 400) Other notes Keep in mind that this is still a preview, it's way rough around the edges, and it's in dire need of additional refactoring. This release requires ASP.NET MVC3, which is itself in preview mode. The views have not yet been converted to use the Razor view engine (because it's slightly hard without the tooling), but the dependency injection features are used here, and that's some delicious goodness that allowed for the destruction of much code. Look for the Ninject implementation of the service locator interface to see how it works. The unfortunate piece of this is that it throws exceptions on every request (and eats them) because the interface requires the throw when it doesn't find an implementation of the controller factory. That's

HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this tring is encoded!

 HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this string is encoded! How can I return unencoded HTML to a Razor view in MVC3? 

MVC3, Razor, and onkeydown

I am trying to create an extension to extend the HtmlTextbox methods to allow our developers to add onkeydown inline javascript to auto click a button with a name they specify.  The relevent code is:... public static MvcHtmlString(this HtmlHelper htmlHelper, string name, string buttonName, object value, IDictionary<string, object> htmlAttributes { if (htmlAttributes == null) { htmlAttributes = new Dictionary<string, object>() } else { if (htmlAttributes.ContainsKey("onkeydown")) { return htmlHelper.TextBox(name, value, htmlAttributes); } } htmlAttributes.Add("onkeydown", string.Format("if (event.keyCode==13) $('#{0}').click();", buttonName)); return htmlHelper.TextBox(name, value, htmlAttributes); } The problem is that the $('btnTest').click() gets encoded to $(#x39;btn#x39;).click(); So, my question is, in razor, how can we ever put these characters in the attributes of a control (wheter it is a textbox, or any other) if it will always get encoded. OR is this a temporary thing (since it is preview 1), and will be fixed?   chad  

MVC3 Preview - Suggestions and a bug


I have a few suggestions regarding the MVC3 preview:

1. I don't believe having a alias for ViewData called View is correct. It is going to cause confusion across teams or within teams on the same project. I can appreciate writing less code, but I don't believe writing View versus ViewData is really any help. You guys have done a great job with the Razor syntax, but I think there is such as thing as taking it too far. Next thing you know, RenderBody() because rb() and @section becomes @s and so on. I'd hate to see MVC going down this route.

2. I feel that one should be able to put the open curly on the line after the @ symbol, so that code can be aligned correctly and curlys can be aligned correctly. for example in multi-line statements, I'd like to be able to do the following



    View.Title = "ooblx - The Knowledge sharing platform";
    LayoutPage = "~/Views/Shared/LayoutSite.cshtml";    

    View.Title = "Razor is great!";

    LayoutPage =

MVC3 Razor - Option to Not have Html encoding


Since all calls to methods (using Razor View Engine and syntax) that return strings have their result Html encoded, is there a way (or an option) to not have the return values html encoded?

For example if I have a simple method like so:

protected string RenderTable(IEnumerable<T> data)
  /* Return some html */

and then in a view (using the Razor View engine) I have code like this:


I'd like the returned string to be inserted into the view as-is and not Html encoded.

What are my options?

MVC3 : Validation parameter names in unobtrusive client validation rules must start with a lowercase


I am migrating my application to MVC3 and getting this error message

Validation parameter names in unobtrusive client validation rules must start with a lowercase letter and consist of only lowercase letters or digits.

How can I ovoid it without going and modifying all my ViewModels

Tank you for your help 

MVC3 Beta requires WebMatrix.Data?


Switching a project from MVC3 Preview 1 to MVC3 Beta 1 and getting the following error when running:

Compiler Error Message: CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?)

This is on the home/index view which is generated from Razor. The generated class is:

Line 1:    #pragma checksum "C:\Dev\Furld\src\Web\Views\Home\Index.cshtml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "7DA68551EE4CE5365FE9A03790329360"
Line 2:    //------------------------------------------------------------------------------
Line 3:    // <auto-generated>
Line 4:    //     This code was generated by a tool.
Line 5:    //     Runtime Version:4.0.30319.1
Line 6:    //
Line 7:    //     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    //     the code is regenerated.
Line 9:    // </auto-generated>
Line 10:   //------------------------------------------------------------------------------
Line 11:   
Line 12: 

MVC3 Beta Razor Views - not partial classes


Why are Razor views not generated as partial classes? Making them partial classes gives us the option to have a code behind where we can do some of the stuff we're forced to do in the template itself in the code behind file.

Yes, I know the standard "go-to" thing is Html helper but I don't want to use Html helpers for these things as they are too specific to the view in question and besides, having a clutter of extension methods is just not the way to go.

I'd like to see Razor views generated as partial classes.

MVC3 Razor - Create a instance of a View


In my controller method, I'm trying to create an instance of a View (cshtml file) before I wrap it around an ActionResult and return it.

Since there is no "class" for Razor Views to speak off, how does one go about creating an instance of a Razor View?

MVC3 beta Razor View Base class/inheritance issues


There seem to be a few issues in the way Razor views are designed and the code generated

1. Descendants of WebViewPage are forced to override Execute() (since it is abstract) but that method is never called. Why?

2. The virtual method ConfigurePage is never called in descendants that override this method.

3. CreatePageFromVirtualPath is no longer virtual. This was the one method that gave us access to the Layout Page (Master Page) instance. Now we no longer have this access. Why was this done?

How can one get access to the instance of a Layout page?

MVC3 Beta Interfering with Classic ASP Form Posts


Unfortunately we have classic ASP that must co-exist with MVC in the same site. I'm doing some testing with MVC3 beta and ran into a strange issue with form posts in classic asp that does not appear in the the preview or in prior versions of MVC. To repro the issue simply create a stock MVC3 beta project and run it under IIS7.5 (Not the development server). Then add a couple of classic asp files; one that posts to another:


<form method="post" action="process.asp">
<input type="text" name="yada">

MVC3 Beta Source Code


I cant seem to find the source code for the MVC3 beta release. The source code on the codeplex site hasent been updated in a few months. Is the MVC source repo somewhere else?



MVC3 fails on Win2003 R2 IIS6


I can't get my MVC3 app to run on Win2003 R2 IIS6 (32bit).  I get the following compile error which doesn't make sense since the path's to the assemblies all seem correct.

Server Error in '/MobileTest' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'model' does not exist in the current context

Source Error:

Line 1:  @model CastleMobile.Models.LogOnModel

Line 2:  

Line 3:  @{

Source File: d:\WebSites\SchoolIsland.com\MobileTest\Views\Account\LogOn.cshtml

Line:  1

Show Detailed Compiler Output:

c:\windows\system32\inetsrv&gt; &quot;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe&quot; /t:library /utf8output /R:&quot;C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll&quot; /R:&quot;C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll&quot; /R:&quot;C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebP

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend