Using ASP.NET MVC & Spark, I have a view that is listing a number of searches. The view has the following declaration at the top:
<viewdata model="IEnumerable<SearchModel>" />
On the same search page, I also render a partial which is used as the content of a popup window that enables users to add new searches.
My problem is: in the partial view I want to make use of strongly typed HTML helpers and write:
${Html.TextBoxFor(model => model.SearchPhrase)}
But when I add another:
<viewdata model="CreateSearchModel" />
at the top of the partial view file, Spark fails with Only one viewdata model can be declared.
I can use normal HTML helpers, but how might I get the benefit of using strongly typed HTML helpers in this partial view - or is there a completely better way of doing this?
Instead of <use file="partial"/> try to do
# Html.RenderPartial("partial", mydata);
This should workaround the single Model limitation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With