Reputation: 47567
In views i`m passing model strongly typed way like this:
System.Web.Mvc.ViewPage<HomeModel>
And then just use it:
<%= Model.Greeting %>
How it would be possible to use strongly typed model in layout?
Without strongly typing i would probably add necessary data at controller factory, then use it through (LayoutModel)Viewdata["LayoutModel"]).Tralala, but i`m looking for better way.
Upvotes: 0
Views: 940
Reputation: 28153
Create strongly typed property in your View:
<script runat="server">
protected LayoutModel LayoutModel
{
get
{
return ViewData["LayoutModel"] as LayoutModel;
}
}
</script>
Upvotes: 1