Questions tagged [displayfor]

HTML.DisplayFor was added in ASP.NET MVC 2 to improve upon HTML.Display, with the main difference being that DisplayFor will give compiletime errors and Display will give runtime errors.

40 questions
8
votes
2 answers

Slow DisplayFor performance in ASP.NET Core MVC

In my current application I'm generating a fairly lengthy table to display to the user. I've been seeing some serious performance issues with it, which I've tracked down to usage of @Html.DisplayFor, and I'm not entirely sure why. Edit: I've…
Doddler
  • 93
  • 1
  • 7
7
votes
3 answers

ASP.NET MVC. How use DisplayNameFor in order to create a table heading and body?

How get a property display name using DisplayNameFor()to build a table header. for instance: @model IEnumerable
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
4
votes
1 answer

replace character in text generated by html.displayfor(function

A webpage currently gives a device ID with hyphens in the number, I want to replace - with : instead (that is to say, replace any hyphens with a colon), but only at display time. I'm pretty confident this is line that is generating the device ID…
notAduck
  • 190
  • 1
  • 3
  • 13
3
votes
3 answers

How to get enum from model into view with displayfor

I have trouble getting a view populated by a enum value from a model correctly. I tried reading up from this thread to help me out with a htmlhelper, with no prevail: How find the enum name for corresponding value and use it in DisplayFor? public…
Joel Wahlund
  • 271
  • 1
  • 3
  • 13
2
votes
1 answer

Iterate over objects of an Enum in C# View

I have the following cshtml code in a View called ViewDepartment.cshtml @model DepartmentViewModel
kesarling He-Him
  • 1,944
  • 3
  • 14
  • 39
2
votes
2 answers

Enable CheckBox with DisplayFor

I have a web application made with ASP.NET MVC 5. In this application I have a view which display a list of information. In this list I display a boolean information with @Html.DisplayFor(modelItem => item.valide). So a CheckBox is displayed and…
Adrien
  • 2,866
  • 4
  • 23
  • 46
2
votes
0 answers

System.InvalidOperationException Stack empty when using StructureMap MVC5 package

After installing StructureMap.MVC5 package got next exception System.InvalidOperationException Stack empty. in case when you try to display circular object dependency with partial view. @model WebApplication.Models.Test @foreach (var val in…
2
votes
1 answer

Html.DisplayNameFor DataType.Url

I have a simple view model public string LinkName { get; set; } [Display(Name = "Url")] [DataType(DataType.Url)] public string Link { get { return string.Format(/*some link building logic*/); } } But when I try to display it in view…
Icen
  • 441
  • 6
  • 14
1
vote
1 answer

.Net Core Razor page with multiple drop-down's for the same entity

Is there any way I can have multiple drop-down menu displaying the data from the same database entity on the same razor page without creating several classes with new IDs (e.g. ResourceID; ResourceID1; ResourceID2) I am able to display the drop down…
1
vote
1 answer

What is the Exact use of DisplayFor in mvc razor view?

What is the Exact use of DisplayFor in mvc razor view? Because it will show only string that matches the model property we pass. But in Razor view, we can directly show the property value using model.propertyvalue What is the difference between…
1
vote
1 answer

Unable to apply a css class to my @Html.DisplayFor inside a WebGrid, inside my asp.net MVC 5 web application

I have the following code inside my asp.net MVC Razor view:- @{ List allLevels = ViewBag.AllLevels; var gridcolumns = new List(); gridcolumns.Add(new WebGridColumn() { …
John John
  • 1
  • 72
  • 238
  • 501
1
vote
1 answer

Html.DisplayFor shows tags as plain text

@Html.DisplayFor(model => model.Description)
This is the output this code gives, while the output should only be "Test". How to hide the Span tag?
Micha Sprengers
  • 139
  • 1
  • 1
  • 10
1
vote
0 answers

How to specify in metadata which column to use for display value

I am making a generic controller which receives a string containing table name and then displays list page. Display parameters such as field formatting are specified in metadata. My plan is to use one controller, one view for list, one view for…
ttaaoossuuuu
  • 7,786
  • 3
  • 28
  • 58
1
vote
2 answers

How to display selectedlist selected value by id?

I have Category model public class Category { //[PlaceHolder("Select file")] //[UmbracoRequired("Form.Label.Import.SelectFile")] //[UmbracoDisplay("Form.Label.Import.SelectFile")] //[Required] public int Id { get; set; } …
nickornotto
  • 1,946
  • 4
  • 36
  • 68
1
vote
1 answer

Create an ActionLink for a DisplayFor value

I have coded a C# MVC 5 Internet Application and have a question about an ActionLink in a View. I have the following code:
Is it possible to create an ActionLink for this above…
Simon
  • 7,991
  • 21
  • 83
  • 163
1
2 3
@Html.DisplayNameFor(? => ?.prop1) @Html.DisplayFor(modelItem => item.mapLocations.Count)