RSS

Monthly Archives: August 2012

ASP.NET MVC Model Metadata

Properties about the model and its container

Model and ModelType Retrieves the value and type of the model itself. Although the model value itself may be null, we may still know the type of the model (for example, we can derive that information from the lambda expression).
ContainerType and PropertyName Retrieves the type of the container object and the name of the property that this value came from. Not all models come from properties, so these may be null.
Properties Retrieves a collection of ModelMetadata objects which describe the properties of the existing model.

Metadata about the model

ConvertEmptyStringToNull A flag which indicates whether empty strings that are posted back in forms should be converted into NULLs. Default: true
DataTypeName A string which can used to give meta information about the data type (for example, to let you know that this string is actually an e-mail address). Some well-known data type names include “EmailAddress”, “Html”, “Password”, and “Url”. Default: null
Description A long-form textual description of this model. Default: null
DisplayFormatString A format string that will be used when displaying this model value in a template. Default: null
DisplayName The display name of this model value. Used in templates and Html.Label/LabelFor to generate the label text. Default: null
EditFormatString A format string that will be used when editing this model value in a template. Default: null
HideSurroundingHtml A flag which indicates that this field should not have any of its surrounding HTML (for example, a label). Often used when a template will be generating a hidden input. Default: null
IsComplexType A flag which indicates whether the system considers this to be a complex type (and therefore will default to the complex object template rather than the string template). Not user-settable
IsNullableValueType A flag which indicates whether the model is a nullable value type (namely, Nullable). Not user-settable
IsReadOnly A flag which indicates if this value is read-only (for example, because the property does not have a setter). Default: false
IsRequired A flag which indicates if this value is required. Default: true for non-nullable value types; false for all others.
NullDisplayText The text which should be used when attempting to display a null model. Default: null
ShortDisplayName The short display name of this mode value. Intended to be used in the title of tabular list views. If this field is null, then DisplayName should be used. Default: null
ShowForDisplay A flag which indicates if this model should be shown in display mode. Default: true
ShowForEdit A flag which indicates if this model should be shown in edit mode. Default: true
SimpleDisplayText Text which should be shown for this model when summarizing what would otherwise be a complex object display. Default: see below
TemplateHint A string which indicates a hint as to what template should be used for this model. Default: null
Watermark Text that might be displayed as a watermark when editing this model in a text box. Default: null

Helper methods

GetDisplayName() This method can be used to get a display name for the model. If DisplayName is not null, it returns that; then it checks if PropertyName is not null, and if so it returns that; failing all those, it returns ModelType.Name.
GetValidators() This method can be used to retrieve the validators that are applicable for this model. These can be used to either run server-side validation on this model, or to generate the client-side validation rules.

Read more on:

Brad Wilson’s ASP.NET MVC Template

MSDN ModelMetadata Class

Advertisements
 
Leave a comment

Posted by on August 30, 2012 in References

 

Tags: ,

ASP.NET Universal Providers Membership

Previously, there are more tables created in database when you install ASP.NET Membership. The tables are (vary depend on features you install):

aspnet_Applications
aspnet_Users
aspnet_Profile
aspnet_Roles
aspnet_UsersInRoles
aspnet_Memberships
aspnet_PersonalizationPerUser
aspnet_Paths
aspnet_PersonalizationAllUsers
aspnet_WebEvent_Event
aspnet_SchemaVersions

Detail instruction to install ASP.NET Membership can be found here.

New ASP.NET Universal Provider Membership offer much simpler membership schema in ASP.NET. There are only 6 tables:

Applications
Users
Memberships
Roles
Profile
UsersInRoles

As you can see, the name is also simplified.

Read more about the post here:

Introducing System.Web.Providers
ASP.NET Membership Schema Created Automatically

 
1 Comment

Posted by on August 30, 2012 in General

 

Tags: , ,

 
%d bloggers like this: