Wednesday, July 11, 2012
Tuesday, July 10, 2012
Data Annotation Validation in ASP.NET MVC
http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs
public class Product { public int Id { get; set; } [Required] [StringLength(10)] public string Name { get; set; } [Required] public string Description { get; set; } [DisplayName("Price")] [Required] [RegularExpression(@"^\$?\d+(\.(\d{2}))?$")] public decimal UnitPrice { get; set; } }
Monday, July 9, 2012
Write Less Code
http://mikegrouchy.com/blog/2012/06/write-less-code.html
When you think about it though the fact that most of your time will be maintaining the terrible code you wrote, writing less code and not creating more work for yourself will start to look like an exceptionally good idea.
Really software development job is to think, your job is to think about the problem at hand, devise an elegant solution and then turn that solution into software.
Thursday, July 5, 2012
How to set maxlength for a Textbox in MVC3?
In model add following attribute:
[StringLength(30, ErrorMessage = "Name cannot be longer than 30 characters.")]
public string Name { get; set; }
$(“#name”).attr(“maxlength”,20);
[StringLength(30, ErrorMessage = "Name cannot be longer than 30 characters.")]
public string Name { get; set; }
Try a couple of others way, doesn’t work:
@Html.EditorFor(model
=> model.Name, new { @maxlength = "2" }) $(“#name”).attr(“maxlength”,20);
Subscribe to:
Posts (Atom)