0

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.

1 Answer 1

1

Create strongly typed property in your View:

<script runat="server">
    protected LayoutModel LayoutModel
    {
        get
        {
            return ViewData["LayoutModel"] as LayoutModel;
        }
    }
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

It's a bit better, but still not what i`m looking for.
Haven't found anything better so far. :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.