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

ASP.NET MVC Html Helper: Adding a validation in an enum ddl

I'm pretty new in ASP.NET MVC. And I'm very sorry for this question. What my goal is: To add a validation using Html Helper of ASP.NET MVC on an enum ddl. Model public enum SampleEnum { Active = 1, Inactive = 2, Pending = 3 } public class…
Josh
  • 223
  • 1
  • 6
0
votes
1 answer

Add tooltip to @Html.Grid Column

I have the following @Html.Grid @Html.Grid(Model).Columns(columns => columns.Add(c => c.NumEM).Titled(Html.DisplayNameFor(model => model.NumEM).ToString()).SortInitialDirection(GridSortDirection.Ascending); columns.Add(c =>…
G.AOUDIA
  • 15
  • 7
0
votes
1 answer

asp:listbox how to provide data?

I'm having some trouble with in my MVC-View. The data for the listbox is passed by the controller and accessible via Model.templateList. So now I have to pass these data to the asp:listbox. Is there any way to do this or do I have to use some sort…
Benjamin
  • 3
  • 1
0
votes
1 answer

server side data annotation not working properly for DateTime array type

I have an array type DateTime property in my model for DateRangePickerFor component. Model: public class DateRange { [Required(ErrorMessage = "Please enter the value")] public DateTime?[] value { get; set; } } When the post action is…
0
votes
2 answers

Using DropDownListFor in combination with ValidationMessageFor

I am currently trying to combine the Html Helper functions DropDownListFor and ValidationMessageFor. I am using asp.Net MVC 5 and have generated a model. My goal is to have an HTML select-box, which is generated by the function DropDownListFor. This…
Ali
  • 410
  • 5
  • 21
0
votes
0 answers

Html.CheckBoxfor() in for loop does not display checkbox

Trying to iterate over a list in my view to display user preferences and if they're hecked or not. Here is what I have for now in my view: @for (var i = 0; i < Model.IdentityFields.FieldDefinitions.Count(); i++) { …
j0w
  • 505
  • 2
  • 12
  • 32
0
votes
1 answer

Problem with Bing.AdvancedSearchBox helper method

Is anyone else experiencing problems with the Bing helper in Microsoft.Web.Helpers? The Bing.AdvancedSearchBox helper method tried to load the following javascript file but throws a 404 error. The script is http://www.bing.com/bootstrap.js Has…
Diego
  • 998
  • 1
  • 11
  • 20
0
votes
1 answer

set ActionLink routeValues dynamically

I'm working on reading a value from textBox (let it be Sam): <%= Html.TextBox("Name")%> and then on click of action link: <%: Html.ActionLink("Edit","Edit",routeValues %> I need to route (this URL should open) /Edit/Sam How can I do that?
Lisa
  • 3,121
  • 15
  • 53
  • 85
0
votes
2 answers

Implement an @html.myTelerikGrid extension

I'm trying to do an HTML Extension to render my telerik grid with the common settings If I declare this code into a view everything its fine. @imports Telerik.Web.Mvc @imports Telerik.Web.Mvc.UI @Code Dim gridBuilder As…
neo
  • 83
  • 7
0
votes
2 answers

ASP.NET MVC Html.TextBoxFor dynamic value

I have a scenario where on a certain view I can have 2 different objects of the same type [Customer]. The first one is called Customer, the other one is called CustomerApprove. The latter contains a change in the customer data to be approved. If the…
HerbalMart
  • 1,669
  • 3
  • 27
  • 50
0
votes
1 answer

How to get values in Check boxes from database using viewbag?

I am using view bag to get skills. How to get data from viewbag in @html.Checkboxfor(). ViewBag.ListSkill = GetSkills(); public List GetSkills() { var client = new RestClient(url); var request = new…
Ghost
  • 213
  • 1
  • 2
  • 10
0
votes
0 answers

Display JSON data on dynamically generated textbox (via HTML helpers)

I want to assign the value of "version" retrieved via AJAX call in JSON format to the textbox, but item.version is giving me error. Could anyone please help me with the same. $.each(data, function (i, item) { var row = $("
0
votes
1 answer

How To Set Value To Drop-down list

I am using jQuery to set the second dropdown list items on selection of the first dropdown. At the time of edit action I want to set fetched data to the second dropdown list. I want to set ViewBag.UserLinkedList to the second dropdown list. View: …
Anirudha
  • 23
  • 4
0
votes
1 answer

MVC3 html.TextBox

I have login view that takes a LoginPageViewModel: public class LoginPageViewModel : PageViewModel { public string ReturnUrl { get; set; } public bool PreviousLoginFailed { get; set; } public LoginFormViewModel EditForm { get; set;…
big_tommy_7bb
  • 1,257
  • 2
  • 21
  • 37
0
votes
1 answer

Secure read only and disabled HTML helpers

I have to secure my HTML helpers like textboxfor in MVC in a way if user inspects or f12 and change the value I should take the original value or prompt with an error. Is there any way to achieve it except disabling f12 or inspect option through…