c# - HtmlHelper extension alter the value of the property passed in -
i have html helper display phone numbers text boxes in friendly way. usage: html.phonenumberfor(m => m.phonenumber) i want take number "1111111111" , output "(111)111-1111". have tried updating viewdata of html helper grabbing property expression in html helper extension method, doesn't seem work. so, know how can update value of property in expression object? here code doesn't work: public static mvchtmlstring phonenumberfor<tmodel>(this htmlhelper<tmodel> helper, expression<func<tmodel, string>> expression, object htmlattributes) { var value = modelmetadata.fromlambdaexpression(expression, helper.viewdata).model string; if (!string.isnullorempty(value) && value.length == 10) { value = string.format("({0}){1}-{2}", value.substring(0, 3), value.substring(3, 3), value.substring(6)); var fieldname = helper.viewcontext.viewdata.templatein