开发者

How to create a MVC 2 DisplayTemplate for a field whose display format is dependent on another field?

开发者 https://www.devze.com 2022-12-24 22:54 出处:网络
If I have a property whose display format is dependent on the value of an开发者_如何学Goother property in the view model how do I create a display template for it?

If I have a property whose display format is dependent on the value of an开发者_如何学Goother property in the view model how do I create a display template for it?

The combination of field1's display being dependent on field2's value will be used throughout the app and I would like to encapsulate this in a MVC 2 display template.

To be more specific, I've already create a display template (Social.ascx) for custom data type Social that masks a social security number for display. For instance, XXX-XX-1234.

[DataType("Social")]
public string SocialSecurityNumber { get; set; }

All employees also have an employeeID. Certain companies use the employee's social security number as either the whole employee id or as part of it. I need to also mask the employeeID if it contains the social. I'd like to create another display template (EmpID.ascx) to perform this task.

[DataType("EmpID")]
public string EmployeeID { get; set; }

The problem is that I don't know how to get both properties in the "EmpID" template to be able to perform the comparison.

Thanks for the help.


This might not directly answer your question but I'm wondering why the Employee ID is only sometimes marked out. I know there are legal requirements to doing so for the social but the employee ID is (or should be) somewhat sensitive as well. I would think it would be better to default to marking out both unless the logged in user had whatever privileges made them fully readable.

If you can do this that would probably simplify your logic/design somewhat.


Cant you create a custom ViewModel class containg both SocialSecurityNumber and EmployeeID and create a custom editor template for that class?

0

精彩评论

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

关注公众号