开发者

Can i put a newline in a resourcefile for Client Side Validation?

I have a form with a client side validationsummary.

View:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
    @Html.ValidationSummary()
    ...
    @Html.TextBoxFor(model => model.Example)
    ...
}

I get the text of my errormessage out of a resourcefile, Resources\Resources.resx.

Model:

[Required(Er开发者_StackOverflow中文版rorMessageResourceName = "err_Example", ErrorMessageResourceType = typeof(Resources.Resources))]
public string Example{ get; set; }

Now i want the errormessage to contain a newline.

But when I put \n or <br/> in the text in the resourcefile it does not convert to html..

How can i fix this?


It's HTML, I would have expected the white space to be collapsed, however, something like this blog post which shows you how to intercept the validation summary would work. Instead of wrapping the validation summary in a <div> element as the blog posts demonstrates you could use a <pre> element, or intercept the validation summary and replace \n with <br \>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜