1

In MVC 4, How do i access a model expression inside a BookingPaymentMode.cshtml?

@Html.EditorFor(m => m.PaymentMode, "BookingPaymentMode")

And

@model MVCApplication.ViewModel.PaymentMode
@using System.Text

@{        
    var htmlHelper = this.Html;
    var  metaData = this.ViewData.ModelMetadata;
    var expression=???
}

However I was doing this with HTML helper class

 @Html.RadioButtonForEnum(m => m.Gender)


public static MvcHtmlString RadioButtonForEnum<TModel, TProperty>(
    this HtmlHelper<TModel> htmlHelper,
    Expression<Func<TModel, TProperty>> expression
)
    {

        var metaData = ModelMetadata.FromLambdaExpression(
                                                 expression, htmlHelper.ViewData)

   }

This is how my UI looks.

enter image description here

Payment can be a type of Partly Paid, Fully Paid, UnPaid

Also it has a text box for Partly Paid amount.

I decided to use enum and CustomEditor. Is there a simple way of doing this?

Billa
  • 5,226
  • 23
  • 61
  • 105

0 Answers0