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

How can I invoke `EditorExtensions.EditorFor` in my HtmlHelper?

I use different Models in my CreateView, all inherit from BaseModel. To call the right EditorFor I have created a HtmlHelper that gets the Model and the actual property. But I don´t know how to invoke it. BaseModel: public abstract class…
jwillmer
  • 3,570
  • 5
  • 37
  • 73
0
votes
2 answers

HtmlHelper that Binds Model Propertys. Fluent Interface

I would like to create an HtmlHelper extension method that allows you to set the model instance and then bind properties of this model to render some html. This would be following a similiar pattern close to the Telerik Grid. In the following…
Gabe
  • 49,577
  • 28
  • 142
  • 181
0
votes
1 answer

how to make in css my font family work sans?

I want to make my font family in CSS : work sans how can I make it my code :

hello word

0
votes
1 answer

Getting @Html.DropDownList or select value

I need to get the value of my @Html.DropdownList for adding a condition by its value. But I don't know how can I get that. What should I do? Here's my code. help me for this... @using (Html.BeginForm("Index", "Search", routeValues, FormMethod.Get,…
0
votes
1 answer

How to bind custom HtmlHelper to controller's action parameter

I created my own ASP.NET MVC CheckBoxList HtmlHelper based on examples I searched on the net. The Helper basically creates multiple checkbox inputs on the page: Item1
rro
  • 619
  • 5
  • 22
0
votes
3 answers

My navbar is incorrectly positioned in FF

In IE the navbar is correctly positioned, centered at the top. However in FF it is moved all the way to the right. I have looked through the code and still cant figure it out. Any ideas? Thanks in advance! #wrapper { display: block; border: 0px…
Kyle G
  • 54
  • 6
0
votes
1 answer

MVC / HTML.DropDownListFor / making default option and its value

I have CreateForm action in ProductController. This action uses view with model: ProductSupplierViewModel (consists of Product and List Suppliers). In my CSHTML i have @Html.LabelFor(m => m.Product.Supplier) @Html.DropDownListFor(m =>…
Alex
  • 21
  • 10
0
votes
2 answers

Need help regarding PHP and HTML

I'm currently working on an assignment for my web development course. The premise is to create a simple "concert ordering site". Everything is well, but I keep running into this error message: Notice: Undefined index: chooseTheAmountOfTickets in…
0
votes
1 answer

Display IP ADDRESS in Html.Label using Viewdata

I am trying to pass IP address to my view using ViewData but it isn't displaying correctly. Below is my coding for label: @Html.Label(ViewData["CREATED_LOC"].ToString(), new { @class = "form-control", @disabled = "disabled" }) I inspected in my…
0
votes
1 answer

How to fix RazorEngine issue with Html.HiddenFor

asp.net mvc4 app, targetting .NET framework 4.5.2, working with VS 2019 I am getting a CS0012 error on a razor page at @Html.HiddenFor(x => x.InvoiceId) pointing to the missing assembly reference 'System.Core'. The strange thing is, that the error…
Manu
  • 1,290
  • 5
  • 17
  • 32
0
votes
1 answer

extending @Html.DropDownList mvc3

In my continuing effort to build out my form validation controls, I've gotten to the dropdownlist control and ran into a snag when I tried to customize this one. I've tried using the TagBuilder and a simple String in extension methods to extend this…
0
votes
1 answer

No opportunity to override name attribute for @Html.TextBoxFor in asp.net core 3.1

We are migrating our project from .net Framework 4.72 to .net core 3.1. I have next html helper code: @Html.TextBoxFor(Model => Model.Property, "{0:0}", htmlAttributes: new { maxlength = 8, Name = "Model2.Property" }) But when I inspect html code,…
0
votes
1 answer

append '#div-id' to reference a html element by id using htmlhelper

How do i append to an url like this mysite.com/articles/1/my-first-article the element with the div id #commentList mysite.com/articles/1/my-first-article#commentList <%: Html.ActionLink("text", "action", new {/* ??? HOW TO SET IT HERE ???…
aGuy
  • 217
  • 1
  • 3
  • 8
0
votes
1 answer

Factorial in a form with Java & HTML. What's wrong with my code?

I need to create a simple form with a button that calculates a number into a factorial. The calculation has to be done from the button and the answer needs to pop up in an alert box. Embarisngly I've tried to figure this out for hours but I can not…
bmatthew
  • 1
  • 1