Should be very simple? But need to two steps to do so:
1. Replace EditFor with TextBoxFor
2. Pass html property into TextBoxFor
@Html.TextBoxFor(m => m.Name, new {style = "width:50px"})
Monday, April 1, 2013
How to add data annotations to a class without changing it?
By MetadataType class
- Inherent from it, make it to be base class
- Then use metadata class to add validation data annotations in subclass
- Inherent from it, make it to be base class
- Then use metadata class to add validation data annotations in subclass
[MetadataType(typeof(ModelMetadata))]
public class Model : Base_Class {
}
internal class ModelMetadata {
[Required]
public string Name { get; set; }
}
Thursday, March 28, 2013
Wednesday, March 27, 2013
How to deal with error "System.Data.MetadataException: Unable to load the specified metadata resource" when move edmx entity file to another project?
Cause: the res:// path changed. Need to be modified
Change connection for edmx file from
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
To
metadata=res://projectname/foldername.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
Change connection for edmx file from
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
To
metadata=res://projectname/foldername.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
Subscribe to:
Posts (Atom)