开发者

Working with MVC3 @using to display a control

开发者 https://www.devze.com 2023-04-11 15:01 出处:网络
I have this piece of code in a .cshtml. @using (Html.BeginRouteForm(\"CheckoutShippingAddress\", FormMethod.Post))

I have this piece of code in a .cshtml.

@using (Html.BeginRouteForm("CheckoutShippingAddress", FormMethod.Post))
{
 <div class="enter-address-body">
 @{
 var dataDictPatient = new ViewDataDictionary();
 dataDictPatient.ModelState.Merge(ViewData.ModelState);
 dataDictPatient.TemplateInfo.HtmlFieldPrefix = "PatientInformation";
  @Html.Partial("_CreateOrUpdateAddress", Model.PatientRoom, dataDictAddress)              
  }

what is happening is an error

The m开发者_C百科odel item passed into the dictionary is of type 'Models.Common.PatientModel', but this dictionary requires a model item of type 'Models.Common.AddressModel'.

what i don't understand is i changed the dictionary to want patientmodel and not addressmodel.


You need to make sure the PatientRoom property of your model is declared as a PatientModel (eg. you didn't just change the name to PatientRoom but leave the type as AddressModel, and also that the @model statement at the top of your _CreateOrUpdateAddress model is @model PatientModel.

0

精彩评论

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