Passing additional data value to strongly typed partial views in ASP.NET MVC

Posted by fearofawhackplanet on Stack Overflow See other posts from Stack Overflow or by fearofawhackplanet
Published on 2010-06-14T15:44:47Z Indexed on 2010/06/14 18:22 UTC
Read the original article Hit count: 184

I have an OrderForm domain class, which has property subclasses, something like:

interface IOrderForm
{
    int OrderId { get; }

    ICustomerDetails CustomerDetails { get; set; }
    IDeliveryDetails DeliveryDetails{ get; set; }
    IPaymentsDetails PaymentsDetails { get; set; }
    IOrderDetails OrderDetails { get; set; } 
}

My "Details" view is strongly typed inheriting from IOrderForm. I then have a strongly type partial for rendering each section:

<div id="CustomerDetails">
    <% Html.RenderPartial("CustomerDetails", Model.CustomerDetails); %>
</div>

<div id="DeliveryDetails">
    <% Html.RenderPartial("DeliveryDetails", Model.DeliveryDetails); %>
</div>

... etc

This works ok up to this point, but I'm trying to add some nice ajax bits for updating some parts of the order form, and I've realised that each of my partial views also needs access to the IOrderForm.OrderId.

Whats the easiest way to give my partials access to this value?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc