Showing posts with label MonoRail. Show all posts
Showing posts with label MonoRail. Show all posts

Monday, 23 February 2009

Html Encoding in MonoRail Views

I was surprised that there didn't seem to be a method for HTML encoding using the HtmlHelper in MonoRail. At least, that's what the assembly manifest and documentation would lead you to believe.

It turns out that there is an HtmlEncode method on the AbstractHelper base class, so you can just call HtmlHelper.HtmlEncode() after all!

Wednesday, 9 April 2008

MonoRail Form Validation Documentation

This post describes how to use MonoRail's (v1.0 RC3) built in form validation.

The javascript validation used is Dexagogo's Really Easy Field Validation.

The error messages usually use the title attribute of the input field, which can be inserted automatically by MonoRail. In order to set a custom error message, add a div with id of the form: advice-element-id, where element-id is the id of the input field being validated.

Packaging MonoRail View Components in an Assembly

I recently found myself in a situation where I wanted to package some view components in a separate assembly for reuse, in much the same way as you'd create an assembly of server controls in web forms/ASP.NET.

Obviously this means you need to get rid of any views or compile them into the assembly somehow. Taking a look into the Castle.MonoRail.ViewComponents source code, it turns out there is a "RenderText" method that you can use within your ViewComponent to output view text directly.