开发者

Passing values with the UIHint to the View

开发者 https://www.devze.com 2022-12-28 22:24 出处:网络
With the UIHint you can also store some data on the model so you can react with that in the View. The Sintax as described in some blogs is:

With the UIHint you can also store some data on the model so you can react with that in the View. The Sintax as described in some blogs is:

[UIHint("TemplateToUse",null,"Variable1", "Value1", "Variable2", "Value2", ...)]
public string Something { get; set; }

And then I try to access this on the View with ViewData.ModelMetaData.AditioanlValues but the arra开发者_JAVA百科y returns empty!

Anyone have implemented this already to give me a "Hint" on how to use UIHint for this?


As of MVC3 you can use the AdditionalMetadataAttribute

[AdditionalMetadata("Source", "ThisIsACustomValue")]

which is then accessed in the view as

ViewData.ModelMetadata.AdditionalValues["Source"];

see http://msdn.microsoft.com/en-us/library/system.web.mvc.additionalmetadataattribute(v=vs.98).aspx


check this out: http://www.mikevdm.com/BlogEntry/Key/Using-UIHint-With-ControlParameters-in-MVC

0

精彩评论

暂无评论...
验证码 换一张
取 消