How to display name to a Property in Asp.Net MVC from Code behind ?

Posted by Goud.Kv under ASP.NET MVC category on | Points: 40 | Views : 1114
Easy thing to do., Below code snippet tells you how to do that.

Just add the name for your property in your model as below,

public class myModel {

[DisplayName("Embed Code")]
public string EmbedCode { get; set; }


The above attribute '[DisplayName("Embed Code")]' will automatically sets the name to the EmbedCode property in your view.

In order to display that name in the view., Just call it in your view page as below,

@Html.LabelFor(model => model.EmbedCode)

Comments or Responses

Login to post response