This is a migrated thread and some comments may be shown as answers.

[Solved] NumericTextbox and Razor

1 Answer 116 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Evgeny
Top achievements
Rank 1
Evgeny asked on 30 Mar 2011, 12:45 PM
I'm trying to set up html attributes at IntegerTextBox, but get an error message.
What is wrong?

Code:
@{
            var s = "empty";
            Html.Telerik().IntegerTextBox().Spinners(false)
                    .InputHtmlAttributes(new { class = "t-input InputQuantity" })
                    .HtmlAttributes(new { id = "txtQuantity", class = "Quantity" })
                    .Name("Quantity").EmptyMessage(string.Empty);
}

Error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1513: } expected
 
Source Error:
Line 85:              var s = "empty";
Line 86:             Html.Telerik().IntegerTextBox().Spinners(false)
Line 87:                     .InputHtmlAttributes(new { class = "t-input InputQuantity" }) <- error here
Line 88:                     .HtmlAttributes(new { id = "txtQuantity", class = "Quantity" })

1 Answer, 1 is accepted

Sort by
0
Drew Greenwell
Top achievements
Rank 2
answered on 30 Jun 2011, 04:21 PM
..old post, but just in case someone else runs across your issue..

class
is a reserved word in c#, you need to prepend the word class with the '@' character

change your code to the following
.InputHtmlAttributes(new { @class = "t-input InputQuantity" })
Tags
NumericTextBox
Asked by
Evgeny
Top achievements
Rank 1
Answers by
Drew Greenwell
Top achievements
Rank 2
Share this question
or