Questions tagged [html-helper]

Refers to the `HtmlHelper` class for ASP.NET MVC views.

HtmlHelper is a helper class specific to ASP.NET MVC. The platform includes extension methods for this class that can be used to render HTML markup given the model and other inputs.

The canonical example is the DisplayFor method, which renders a display for a given model property. In Razor syntax, it looks like this, which renders the value of SomeProperty belonging to the current model class:

@Html.DisplayFor(model => model.SomeProperty)

The volume of methods available in HTML Helper is extensive, and they make use of data annotations (for string formatting and client-side validation). Their usefulness makes them a core part of the ASP.NET MVC framework.

2251 questions
0
votes
3 answers

Need help with Java code

I am having a bit of a problem with a linked list. I am generating 40 random integers using a random object from random class and append them to a linked list. This also uses a specified seed. Everything works perfectly minus this one bug. The first…
Jean
  • 1
  • 1
0
votes
1 answer

custom validation attribute error message is displaying prior to validation

I am attempting to use a custom validation attribute to ensure a checkbox ends up checked. However, the validation error is displaying (not styled) as part of the checkbox's label prior to the validation firing. To detail: I have the following…
0
votes
1 answer

html helper @enumdropdownlistfor is not sending the value to the model

enumdropdownlist is used only with strings not integers. i want to show admin management in dropdown in view. if user select admin background value of admin which is 1 send to the model if user select management background value of manage which is 2…
0
votes
1 answer

Better solution of custom htmlhelper,add part of script to ContentPlaceHolder

I have created htmlhelper, I have been wondering, if there is some neater way of doing this. Please feel free to say what i am doing wrong, your suggestions are welcome. /// /// Custom jQuery Picker for object ///
cpoDesign
  • 8,953
  • 13
  • 62
  • 106
0
votes
1 answer

Columns are stuck on the left and not spread out

I can't figure out why my columns are stuck on the left like that and not spread out. nav { float: left; } nav ul { margin: 0; padding: 10px; list-style: none; } nav li { display: inline-block; margin-left: 70px; …
Joshu
  • 460
  • 4
  • 14
0
votes
2 answers

How can I list date values as enumerable values list for ListBox

I'm loading a ListBox from a model which looks like this public class FilterModel { public Learning TypeOfLearning { get; set; } public TeachingYear Teaching { get; set; } } public enum Learning { All, Frameworks, …
0
votes
0 answers

change width of @Html.DropDownListFor dynamically based on the length of text

We all know that this works. @Html.DropDownListFor(m => m.SelectedProvisionalAward, Model.PreviousProvisionalAwardDecisions, new { style = "width: 250px;" }) But how do we make the something like this @{var width =…
0
votes
1 answer

Remove Empty Entry from EnumDropDownListFor

I want to remove the Blank/Empty entry from my EnumDropDownListfor - have searched online and tried below links but nothing seems to work Remove blank/empty entry at top of EnumDropDownListFor box Remove blank entry from…
Ram
  • 527
  • 1
  • 10
  • 26
0
votes
1 answer

How to use Html.Partial() inside of custom html-helper in ASP.NET MVC 5?

I want to create a custom separated from page html-helper that would use partial views functionality, but for some reason Html.Partial("_partialName") doesn't work Content of separated cshtml file in App_Code: @helper MyHelper(IEnumerable
Yes Man
  • 321
  • 1
  • 5
  • 14
0
votes
1 answer

Asp.Net Tag Helper type="date" allows more than 4 digits for Year

I am using the asp.net core tag helper input type="date" and it allows me to type in more than 4 digits for my year. I have tried setting the Display format but i am still allowed to type more than 4 digits for the year resulting in a year that…
0
votes
0 answers

How to modify the Html Resulting from a dropdownlistfor?

I'm working on modifying the CSS of a Select Tag. The Select tag is generated using @Html.DropDownListFor Helper. To change the CSS of the arrow of the select element i need to have a label before or a div incapsulating the select to play with the…
tahtoh
  • 102
  • 8
0
votes
1 answer

How to resolve @ViewBag, HtmlHelper and Linq errors on compile with Visual Studio and MVC 5.2

So I have this code and the screen shot displays the only 3 errors left out of 13. I've updated VS and MVC to 5.2. Here is the controller for ViewBag or where it exists in the code: I need to find a solution for resolving this. I've scoured the web…
Peter The Angular Dude
  • 1,112
  • 5
  • 26
  • 53
0
votes
1 answer

Add css link to HTML of HtmlHelper extension method

I have a HtmlHelper extension method as below. It returns an instance of PagedList.Mvc.HtmlHelper.PagedListPager. The PagedListRenderOptions have specified some css classes. Each view that uses this method needs to add a link to the css file…
pnizzle
  • 6,243
  • 4
  • 52
  • 81
0
votes
0 answers

Can't get datetimePicker of bootstrap.v3.datetimepicker to work in ASP.NET Mvc

I wish to include datetimePicker in one of my form fields. I followed the installation guide on this link: https://eonasdan.github.io/bootstrap-datetimepicker/Installing/ and accordingly added the required files to one of my partial views Below is…
Nice Kloe
  • 59
  • 1
  • 10
0
votes
0 answers

How to use DisplayNameFor with a class constant?

I have this class and would like to display user friendly names. How to do it? public static class NavigationRoles { [Display(Name = "Structure d'offre de service")] public const string STRUCTURES = "STRUCTURES"; } Trying this…
Bellash
  • 7,560
  • 6
  • 53
  • 86