Search code examples
c#asp.net-mvcmvccontribfluenthtml

How to set the "float" style using FluentHtml in MVCContrib


I'm working in ASP.NET MVC 1.0 using MvcContrib FluentHtml version 1.0.

The following code doesn't work because float is a C# keyword.

<%= this.TextBox(m => m.Name).Styles(float => "left") %>

How do I define the "float" css style using the Styles method in FluentHtml?


Solution

  • prefix the argument with an @.

    <%= this.TextBox(m => m.Name).Styles(@float => "left") %>
    

    When using the argument inside the lambda remember to keep verbatim escape the argument.

    @float => @float.ToString()