The HtmlHelper class in the System.Web.Webpages.Html and System.Web.Mvc spaces

In ASP.NET MVC3, I am trying to install a css class that installs a validation assistant method. (Not this question , the accepted answer is just an ADDS class, I want to completely override it.) When I looked at the source of MVC3, I found the ValidationInputCssClassName property in the HtmlHelper class. It is configured and stores the value in the repository, if installed. The get method for the property returns [provider value] ?? [default class name].

Now, if you simply type HtmlHelper.ValidationInputCssClassName ( MSDN record ) in the controller code, you will see that this is a static readonly field. The reason for this is that there are two HtmlHelper classes, one in the System.Web.Mvc and the other in the System.Web.Webpages.Html . The System.Web.Webpages.Html.HtmlHelper.ValidationInputCssClassName property ( MSDN record ) can be set, but it does not seem to affect the generated code no matter where I install it.

What am I missing? And what is the difference between these classes?

+6
source share
2 answers

I'm not sure, but I think System.Web.WebPages.Html intended to use ASP.net WebForms with Razor.

Since ValidationInputCssClassName etc. - all fields are readonly, I think the only way you are going to get around this is to create your own HtmlHelper extension methods so that you can customize this behavior.

From MSDN :

The System.Web.WebPages namespace contains the main classes that are used to render and execute pages created using ASP.NET web pages with Razor syntax.

+3
source

Looking at the description of the namespace, it seems that one of them is designed for Razor and is intended for use with WebMatrix.

Link: http://msdn.microsoft.com/en-us/library/gg549171(v=vs.99).aspx

also:

The System.Web.Mvc namespace contains the classes that are used to create HTML elements.

The types in this namespace are in the System.Web.WebPages assembly and are identical to the equivalent types in the System.Web.Mvc assembly.

Link: http://msdn.microsoft.com/en-us/library/system.web.mvc(v=vs.99).aspx

+3
source

Source: https://habr.com/ru/post/911675/


All Articles