Pergunta

Does the UnobtrusiveJavaScriptEnabled feature of MVC3 work with other view engines beside Razor. I would assume so but all examples I have seen are for Razor
I am currently using the Spark view engine. I have set in my web.conf appSettings..

<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>

I have added reference for dataannotations to the pages/namespaces section of Spark configuration

<add namespace="System.ComponentModel.DataAnnotations"/>

I have included datannotations validation attributes on my model and tried to create a textbox
e.g Html.TextBoxFor(m => m.name); in my view.

However the inputbox has no addition attributes. output is.

<input type="text" value="" name="name" id="name">

If I can get this working I assume the dataannotation extensions should also work.

Foi útil?

Solução

I can't see any reason why unobtrusive javascript validation wouldn't work with other engines such as Spark (but cannot say for sure as myself I've never used it). Make sure you have placed this textbox inside a form generated with the Html.BeginForm helper.

Outras dicas

I think those configuration controls how the html is rendered, so it should not matter which view engine you choose to use.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top