How to set or restrict the length of the text box from code behind in Asp.Net MVC ?

Posted by Goud.Kv under ASP.NET MVC category on | Points: 40 | Views : 947
Below code snippet is used to set length of a string to a property in MVC.

In the Model class of your application,
public class myModel {

public string EmbedCode { get; set; }


Setting '[StringLength(1000)]' to the EmbedCode property allows user to enter text upto '1000' characters and doesn't allows to submit more than that.

Comments or Responses

Login to post response