Does anyone have a great library for missing field helpers of MVC 3 html form?

I am building an application using ASP.net MVC 3 and I wonder if anyone knows a great library for filling in the blanks of the built-in field helpers of the html form?

eg. creating a text field is very simple:

@Html.EditorFor(model => model.TextboxTest) 

But to create a drop-down list I have to write:

 @Html.DropDownListFor(model => model.DropdownTest, Model.DropdownTestData) 

And it should be written as

 @Html.EditorFor(model => model.DropdownTest) 

where DropdownTest is a SelectList.

Here is an example of a solution that can be found here .


The same applies to the list of radio objects: it is not included in MVC (at the moment). There is another good solution that can be found here , and with this solution I could write

 @Html.RadioButtonListFor(model=>model.Item,Model.ItemList) 

So there are accessible solutions, but not structured in the library (accordingly, I did not find them), and I don’t want to copy and paste these solutions together in parts (because I cannot easily update it using NuGet, for example), the whole library will be better, but I could not find her.

Please, help:)

+6
source share
2 answers

Take these solutions from different places if you want to use them and put them in your own library. And if you want to use NuGet to manage your libraries, you can create your own NuGet repository to store this library. You can have a NuGet package dependent on MVC libraries, so all you need to pull is your package and it will include MVC3.

+2
source

While the user interface is completely different for them, there is no functional difference between the drop-down list and the switch list. Both are elements of "Choose one from the list of options." How does the editor EditorFor () find out what you want in any given scenario? At best, you will need something like

  @Html.EditorFor(model => model.DropdownTest, model.DropDownTestData, ListType.DropDownList) 

which is not much better than

  @Html.DropDownListFor(model => model.DropdownTest, Model.DropdownTestData) 

Another issue to consider is how it will distinguish between editing the selection represented by the drop-down list / list of radio buttons and editing the list itself. With a text box, clearly, if you want to edit it, you want to edit its contents, but with a list of options that is not well defined. Consider the difference in user interface between student and teacher of a multi-choice testing application. The teacher wants to create a multiple choice answer list, and the student wants to choose one of the results, but the data for both is presented as a list of question / answer pairs.

In short, I think that any library that provided this functionality would be as complex (if not more) than current methods.

+1
source

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


All Articles