asp.net mvc - How can I set a label, that belongs to a model, dynamically? -


so let's have registration model , have:

[display(name = "")]
public string secretquestion { get; set; }

how can load [display(name = "")] dynamically display name secret question. getting question database , need dynamic.

i don't believe can use unobtrusive validation properties dynamic data. need send information view , display manually.

this can accomplished in many ways, depending on how generating views.

a simple way of doing is:

controller:

myviewmodel.secretquestion = getsecretquestion(); 

view:

@html.displayfor(model => model.secretquestion) @html.textboxfor(model => model.secretquestion) 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -