MaT
MaT

Reputation: 1606

@Value not working

I am using the mvc Editor features but it seems that the @something doesn't work. I don't know why.

@Html.EditorFor(model => model.Password, new { @Value = "xxx" })

This take the model value and not the "xxx".

Thanks a lot for your help !

Upvotes: 0

Views: 391

Answers (3)

Samuel Caillerie
Samuel Caillerie

Reputation: 8275

The @Value works for TextBoxFor but not EditorFor (since it is generic...).

Upvotes: 0

Rahul R.
Rahul R.

Reputation: 6451

You have to remove the second @. if you want your value to come from model, you have to write something like this,

@Html.EditorFor(model => model.Password, new { value = Model.Password})

In either case you have to remove the second @ before value

Upvotes: 1

Lews Therin
Lews Therin

Reputation: 10995

You don't need the @ in front of Value. As you have it already in front of Html. Remove it and it should work.

Upvotes: 5

Related Questions