views:

29

answers:

1

I'm trying to create an input text through the following code so it can hold a date that user can choose in a date-picker jQuery control:

    <%: Html.TextBox("date", null, new {class = "date-pick"}) %>
        <input name="date" id="date" class="date-pick" />

Problem is, I need to specify the "class" attribute for the input text, but "class" is of course a reserved keword in C# :-)

Is there any way to use this override for this?

Thanks!

+7  A: 

Use @class in cases such as this, it should look like this:

<%: Html.TextBox("date", null, new {@class = "date-pick"}) %>

For any attribute that's a reserved word, just prefix it with a @.

Nick Craver
Wow, the syntax highlighter even saw the difference
jayrdub