我正在创建一个强类型助手(参考:SO question)。正如下面代码中的“注释”,是否有可能以某种方式从表示的属性中获取值,从而绕过可选selectedValue
参数?
<Extension()> _
Public Function DatePickerFor(Of TModel As Class, TProperty)(ByVal htmlHelper As HtmlHelper(Of TModel), ByVal expression As Expression(Of Func(Of TModel, TProperty)), Optional ByVal selectedValue As Nullable(Of Date) = Nothing) As MvcHtmlString
Dim inputName = ExpressionHelper.GetExpressionText(expression)
Dim inputValue = selectedValue
//Something like this possible?
//inputValue = ExpressionHelper.GetExpressionValue(expression)
Return DatePicker(htmlHelper, inputName, inputValue)
End Function