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

What does Html.HiddenFor() actually do?

Html.HiddenFor() is used when I want to persist a field on the page but dont want the user to notice it, like the Id field and such, but does it initialize a value for the Id field? If the Id field already has a value, what does it do then? I am…
Mohamed Motaz
  • 391
  • 1
  • 4
  • 13
0
votes
1 answer

javascript game help pls

The game is able to get unlimited money by pressing the button. How do I prevent this? var workbard = document.getElementById("workbar"); function work() { var zaman = setInterval(function () { workbard.value +=1; if (workbard.value ==…
saym nk101
  • 13
  • 1
0
votes
2 answers

Extending/replacing Html.Image for Amazon S3 (or other CDN)

Just want to confirm that there is no way to extend or replace Html.Image functionality without writing a replacement function. I want to write a function that will use Amazon's S3 service for hosting images. The best approach I've come up with is a…
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
0
votes
1 answer

Searchable Dropdown in MVC5/C#

Problem: I have an @html.DropDownList that is populated by a List in my controller (query from ICS_Supplies table, creating a list of supplies available for order). This list is pretty large and users are complaining that it takes a significant time…
ExecChef
  • 387
  • 2
  • 13
0
votes
1 answer

How to enter multiple selections from a selection list into same DB row/col using MVC @html helper

My goal is to make my selection lists, that are countries that load states, that can also select multiple, go into the same col/row in the database with say a comma in between each ID. My expected result is to not have only the last one in the user…
Raymond Riter
  • 47
  • 2
  • 2
  • 7
0
votes
1 answer

MS MVC 3 custom html helper that recieve as parameter the model?

I've written a custom html helper in MVC 3 that receive as a parameter the model my view is based on. What I'm wondering is: can a custom helper access the model without receiving it as a parameter? Is there any way to avoid calling it like this:…
user449689
  • 3,142
  • 4
  • 19
  • 37
0
votes
0 answers

Problems with dropdownList from html to HtmlHelper

I am working in ASP MVC in a crud with search filters, the current one I have: Producto: but i want to make it a dropdownlist try…
0
votes
1 answer

Webgrid with filtered results

I like the Webgrid HTML-Helper in Razor-ViewEngine. Unfortunatly I am facing a problem. Using the built-in sorting and paging functions I loose my filter settings. Above the grid I have a filtercontrol (form), filtering the rows shown in the grid by…
Tobias
  • 2,945
  • 5
  • 41
  • 59
0
votes
1 answer

Call another method onSuccess event of an Ajax call

I have an AJAX call on MVC3 it looks like this save: function () { $.ajax({ url: "@Url.Action("Save")", type:"post", data: ko.toJSON(this), contentType:"application/json", success:…
0
votes
1 answer

Adding a dynamic list of parameters with Html helper

I'd like to be able to feed in a list of parameter names and values into a Html.Actionlink but the helper doesn't create the parameters as I would like. Any ideas how to do this? public class ParameterNameValue { public string ParameterName {…
BMills
  • 881
  • 1
  • 10
  • 24
0
votes
0 answers

Showing product specs using HTML helper

I have this piece of code to show a table of product specs.

Product Specs


@Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.Id) @foreach (KeyValuePair spec in…
Arya
  • 91
  • 1
  • 11
0
votes
2 answers

MVC2 Html.RadioButton - Is there a way to set the InnerHTML using HTML Helpers?

Perfectly normal radio buttons in HTML look like this: First Second Third As far as I…
Scott Baker
  • 10,013
  • 17
  • 56
  • 102
0
votes
0 answers

The type arguments for method cannot be inferred from the usage.Try specifying the type arguments explicitly

The error is :The type arguments for method 'System.Web.Mvc.Html.ValidationExtensions.ValidationMessageFor..........' cannot be inferred from the usage.Try specifying the type arguments explicitly.
Pacman
  • 11
  • 5
0
votes
1 answer

How to make if dependent HtmlHelper usage

Im using asp.net mvc 2.0. I have the following HtmlHelper extension: AdminOnly(HtmlHelper helper, IPrincipal User, string htmlToRender) { //Render Html if have admin access. } I need to modify it to use in such a…
0
votes
1 answer

CheckBoxFor Nullable Boolean Serialization

I have a nullable boolean in a class that I'm using for a model for a partial view. By doing the following: @Html.CheckBoxFor(p => p.policies.is_a_company.Value, new { @class = "form-control", @Id = "policies.is_a_company", @Name =…