views:

242

answers:

1

This is part of my spark partial view (it is called TaskSearch):

${ Html.DropDownList("Search.Status", Model.Statuses, "All") }

it is generated by non-spark view with code:

<% Html.RenderPartial(ControllerActions.TaskSearch, ViewData["TaskSearchModel"]); %>

Spark generates view class that contains

Output.Write(H( Html.DropDownList("Search.Status", Model.Statuses, "All") ));

which instead of creating html, creates html encoded html code, so I see html tags on output page, instead of dropdown list. I am propably missing something, but what should I do to disable H() usage in generated view?

If I use

<%= Html.DropDownList("Search.Status", Model.Statuses, "All") %>

everything works fine.

+2  A: 

I had

<spark>
    <pages automaticEncoding="true"/>
</spark>

in my web.config and

settings.SetAutomaticEncoding(true);

in global.asax and didn't notice it. Changing to false resolved the problem.

LukLed
Leaving automaticEncoding set to true is kind of a good idea anyway, as it protects you from XSS attacks. You can always force unescaped output with !{} (i.e. !{"<p>Hello <strong>World!</strong></p>"}. Check http://sparkviewengine.com/documentation/configuring#Sparksettingsinconfigfile
Daniel Liuzzi
I used automaticEncoding = "true":) Didn't notice !{} earlier, I used <%= =>. Thanks. I am coming back to standard view engine, because it works much better with Intellisense and ReSharper.
LukLed