#11 Bind Attribute in MVC

There are cases where you want to limit/restrict  the properties of a model that is submitted to the server.

Model class :


[Bind(Exclude="Rid")] ---- Rid properties is excluded from model.

public class ReviewModel

{
public int Rid { get; set; } -- AutoGenerated ,User need not submit it
public String RName { get; set; }
public String RLocation { get; set; }
public int Rating { get; set; }
}

In the above example,Rid is Auto generated and user need not submit it when posted from View. Rid is excluded by using Bind attribute annotation. 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s