Is it possible to use a Model inside the layout page? For instance, we have a a model that contains several forms to be rendered onto the page. One form is a search form used to search our site and we would like to add that to the layout page. Now we want to take advantage of the html.editorfor helper to print out the form. The search form can differ a bit depending on what view that is presented (which is the reason to why we don't want to type it in html). So how can i pass this search for to the model and still take advantage of the html helper to print it out?
Asked
Active
Viewed 2,342 times
1 Answers
5
Edit: Corrected :-)
Yes, absolutely.
Just put:
@inherits WebViewPage<MyModelName>
at the top of the layout page, and this will set the base class, with the Model property typed as MyModelName
.

Danny Tuppeny
- 40,147
- 24
- 151
- 275
-
Actually, I made a mistake. I actually have `@inherits WebViewPage
` in the top of my layout page. You can see the code I'm using here: https://bitbucket.org/DanTup/dantup-blog/src/64bbc6cd8a5b/DanTup%20Blog/Views/Shared/_Layout.cshtml – Danny Tuppeny May 19 '11 at 16:32