0
public class Clubber
{
    public virtual int ObjectID { get; set;}
    public virtual User OwnerUser { get; set; }
    public virtual int BlackPoint { get; set; }
    public virtual bool ToSendSMS { get; set; }
}

and

public class User
{
    public virtual int ObjectID {get; set;}

    [Required]
    public virtual Permission Permission { get; set; }
}

and i try to make Dropdown list for the OwnerUser property by the ObjectID

@Html.DropDownList("OwnerUser.ObjectID", (SelectList)ViewBag.OwnerList)

and when I try to save its says that Permission Required how can i disable the permission validation in this case?

2 Answers 2

1

I will suggest to use ViewModel which will have required fields to render on UI and may be specific to you Controller - Action.

see this SO link on best practices of using ViewModel -

Sign up to request clarification or add additional context in comments.

Comments

0

Use following in action.

[Bind(Exclude = "Permission")] 

To exclude multiple attribute, you can do

 [Bind(Exclude = "attribute1,attribute2,attribute3")] 

1 Comment

@dor: You can exclude more than properties using comman after each attribute name like [Bind(Exclude="OBJECTID,Permission")]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.