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

Create links to tagged list from an array of tags

I just followed a tag tutorial (https://book.cakephp.org/3.0/en/tutorials-and-examples/cms/tags-and-users.html) on the Red Velvet Cookbook. I was successful in adding tagging to my website. Though I feel it needs a couple more things. The comma…
0
votes
1 answer

Foreach of DropDownList html helper with value from the foreach itself

I'm just inquisitive if this is possible. If so, please help me. Everything is already set and valid like the: -Model.info: public class info{ public string information{get;set;} } -ViewBag.Infos: ViewBag.Infos = new SelectList(new…
Hadji
  • 96
  • 6
0
votes
1 answer

Assign viewbag int value to Html Helper Dropdown list

I am trying to assign int value present in view-bag to drop-down list. View @Html.DropDownListFor(m => m.nStatusID, ViewBag.ReasonTypeList asSelectList,ViewBag.nStatusID, new { @class = "form-control" }) controller action contain- var Complaint =…
0
votes
1 answer

How to create an input element in c# mvc which allows only ipv4 and ipv6 address with html validation?

I want to use an input field in MVC to enter an IP address either IPv6 or IPv4. It would be very helpful if it does include the address masking. I tried using html attribute 'pattern' with value @pattern =…
Ashish Dehariya
  • 216
  • 3
  • 10
0
votes
1 answer

Assign data-* attribute in an Html input helper with it's own value

I'm trying to achieve the two below. @Html.DropDownListFor(m => m.task_drop, new SelectList(ViewBag.dropList," "), new { @class = "task-drop", id = "dropping", type = "text", placeholder = "Drop the bass", data_tooltip="(this's value)" }) and…
Hadji
  • 96
  • 6
0
votes
2 answers

MVC 3 - HTML Helper

I was going to use declarative HTML helpers, but then found out that they have not been implemented in a release of MVC 3. I'm trying to get old HTML helpers to work with the following code: private static String GenerateSingleOptionHTML(Question…
user338195
0
votes
1 answer

send HTML tags in form field on form submit

im trying to submit a form to my controller action, one of the form field contains HTML tags like

    i have added and in my web.config, also i have…
Rafay
  • 30,950
  • 5
  • 68
  • 101
0
votes
1 answer

Rendering templated HtmlHelper with MVC3/Razor

I have a HtmlHelper that renders a grid as a table, in MVC2 I would call it from the view using the following syntax... <%= Html.MyLibrary().Grid() .Name("MyGrid") .Width("100%") .Render() %> Notice it uses…
MarkB
  • 174
  • 14
0
votes
1 answer

How to return a value/s of a dropdownlist using select2 in asp.net?

I am currently learning front-end development in asp.net and I seem to be lacking some fundamental understanding when it comes down to dropdownlists in particular. My goal is what I thought should be very straight forward and simple - to produce a…
0
votes
1 answer

How to enable Intellisense in Html Helper with MVC3?

I basically followed this article: http://develoq.net/2011/how-to-create-custom-html-helpers-for-asp-net-mvc-3-and-razor-view-engine/ My HtmlHelper class is located in the root directory of my MVC project: using System.Web.Mvc; namespace…
Dimskiy
  • 5,233
  • 13
  • 47
  • 66
0
votes
1 answer

How to use [(ngModel)] in html helper controls such as @Html.DropDownList

I am using angular 7 and MVC I need to use [(ngModel)] in html helper controls, I tried the following way @Html.DropDownList("StateCode", StateList, new { @class = "form-control", @id = "StateCode", @name = "StateCode", ng_model =StateCode"…
Sumith Jose
  • 69
  • 1
  • 14
0
votes
1 answer

html helper checkbox not working as required

I have a questionnaire, on first page if user selects the checkbox (generated by below code) in the next page it should not be checked and when user goes back to previous it should be checked. nothing is working, while debugging the view it shows…
RAhul Apte
  • 213
  • 2
  • 10
0
votes
1 answer

how to inject javascript into a HTMLhelper text field

i created a form using asp.net mvc, i am using entity framework database.on the form there are text fields, how do i add javascript inside a html helper. bellow is the textfield @Html.TextAreaFor(m => m.ShortSummary, htmlAttributes: new { onkeyup…
0
votes
0 answers

TreeView in ASP. NET Core MVC using RAZOR engine without JS libraries

I have an issue that usual System.Web.UI.WebControls with @(Html.TreeView(Model) is not implemented in ASP.NET Core. Is it possible to a implement hierarchy tree view with recursion using only Razor, html? There is my tree node model: public class…
Olli
  • 27
  • 9
0
votes
1 answer

auto closing custom helper

I am trying to implement auto closing custom helper. I have found how to to this below: Custom html helpers: Create helper with "using" statement support I have done everything except: what i am supossed to return here? public static Action…
cpoDesign
  • 8,953
  • 13
  • 62
  • 106