Skip to main content

Posts

Showing posts from April, 2009

An Asp.Net Validation Framework (Part 3)

An Asp.Net Validation Framework (Part 1)An Asp.Net Validation Framework (Part 2)Unfortunately, if you’re using LINQ to SQL or the Entity Framework, you can’t add the custom attributes we need for validation. You could generate your entity model and then simply use those generated objects but you would lose the ability to use the designers. I prefer to leverage the code we’ve written.publicclass ValidatableOrmBase
: ValidatableBase
{

private List<CustomPropertyAttributeListItem> customPropertyAttributes;

public List<CustomPropertyAttributeListItem> CustomPropertyAttributes
{
get
{
if (customPropertyAttributes == null)
{
customPropertyAttributes = new List<CustomPropertyAttributeListItem>();
}
return customPropertyAttributes;
}
}

publicoverridebool Validate(bool clearBrokenRules)
{
base.Validate(clearBrokenRules);
foreach (CustomPropertyAttributeListItem cvli in CustomPropertyAttributes)
{

Asp.Net MVC and Sys is undefined

If you’ve run into the Sys is undefined message, check to make sure that you’ve included the following:<scriptsrc="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>"type="text/javascript"></script> and <scriptsrc="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>"type="text/javascript"></script>
You can include them in your masterpage or each individual page.