How to create a MVC 2 DisplayTemplate for a field whose display format is dependent on another field
Posted
by Glenn
on Stack Overflow
See other posts from Stack Overflow
or by Glenn
Published on 2010-03-24T00:19:17Z
Indexed on
2010/03/24
0:23 UTC
Read the original article
Hit count: 989
If I have a property whose display format is dependent on the value of another 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.
© Stack Overflow or respective owner