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
1 answer

mvc : control specific required validation

I am using mvc 2.0 with C#.Net In my view page, I am creating multiple controls with required field validations. to plot my controls, I am using for loop through my mode object which is actually a collection of business object. For my TextBox…
Anil Soman
  • 2,443
  • 7
  • 40
  • 64
0
votes
1 answer

A checkbox for selecting all checkboxes generated by CheckBoxFor

I am using CheckBoxFor to create a form of a bunch of checkboxes. I have added a class to these checkboxes but since CheckBoxFor doesn't add the class to the hidden false checkbox, I can't select groups of these generated checkboxes based upon it.…
MKF
  • 426
  • 7
  • 24
0
votes
1 answer

CakePHP DIV option for Dropdowns

It's easy to configure a Div using the form helper for standard input boxes. An example int he manual is... echo $this->Form->input('User.name', array('div' => 'class_name')); However, I can't achieve the same thing with dropdown menus? Can…
Kieran
  • 2,554
  • 3
  • 26
  • 38
0
votes
1 answer

Optional Data Attributes on Input [Html]

Is there a way to have an optional data attribute i.e data_val_required or required on an input/select? @Html.DropDownListFor(x => x.PositionId, Model.Positions, new { CurrentInput.Required ? data_val_required = "Please select a position" :…
Bad Dub
  • 1,503
  • 2
  • 22
  • 52
0
votes
4 answers

How to configure Checkboxes Materialize Css in Web application Asp.Net MVC

How do I configure Checkboxes in Asp.Net MVC Razor. Since in the documentation we have the following configuration Materialize for checkboxes :

  

And in…
Cyberlacs
  • 191
  • 1
  • 7
0
votes
4 answers

How to Remove Client-Side Validation on a textboxfor for multiple emails?

I am creating an MVC application in which I will have an input field for a list of emails. In order to do so, I added multiple in order to allow for the user to enter a comma separated list of emails. By doing it this way, I'm able to have input…
0
votes
1 answer

RadioButtonFor for a list of objects mvc

I have a Model : public class Period { public int Id { get; set; } public bool Selected { get; set; } public string DisplayText { get; set; } public string PickerFormat { get; set; } } and the ViewModel (just involved part): public…
Manta
  • 490
  • 5
  • 18
0
votes
1 answer

Implement a HtmlHelper extension that uses the routing system

I'm trying to implement my own extension for HtmlHelper that will output a link in a similar fashion to ActionLink. I know I can do this easily with TagBuilder for instance, but I'd like to take advantage of the routing system ability to construct…
Paul
  • 1,224
  • 2
  • 14
  • 31
0
votes
1 answer

Bootstrap forms changing size when they are validated

I'm new with frontend, so I'm starting with bootstrap 'to make my life easier (or not), but I'm having some trouble adjusting forms When validating those fields, the forms change the size, how would can i standardize those sizes? Already tried to…
0
votes
1 answer

jQgrid Json Format Help Request

I cannot import my json data into a jQgrid. I get an empty grid. I hope someone has a solution. The json data seems to be improperly formated. It looks like this: { "total": "3", "page": "1", "records": "71", "rows": { …
0
votes
1 answer

MVC 2 - Use HtmlHelper.BeginForm inside method that creates a dynamic form

I have a method like this: public MvcHtmlString RenderStuff(HtmlHelper htmlHelper) { TagBuilder div = new TagBuilder("div"); //Dynamically add elements to form e.g. div.InnerHtml +=…
Rob
  • 10,004
  • 5
  • 61
  • 91
0
votes
1 answer

Dynamically Creating IDs in an ASP.net MVC 5 HTML Helper Extension

I will like to dynamically add a unique ID to an hidden field as I loop through a list in the view. Here's what I have: @foreach (var food in Model) { if (counter != 0 && counter % 4 == 0) { …
Samseen
  • 87
  • 5
  • 13
0
votes
3 answers

MVC form doesn't validate

I am very new to MVC 3. I am using custom helpers for the controls but when i submit the form, the control is not being validated. Can some one tell me if i am missing something? Following is the code snippet. public static MvcHtmlString…
0
votes
2 answers

problems with html helper method

I can't figure out how to send a parameter from a dropdownlist to my model. Could someone please show me an example of how to do this?
0
votes
0 answers

Add annotation attribute to custom html helper

The PropertyInfo has a property (CustomAttributes) which returns the attributes applied to the property for which html helper is being created. How do we add another annotation during the helper creation? For example, for every property on which…
ZerosAndOnes
  • 1,083
  • 1
  • 13
  • 25