Yogesh
Yogesh

Reputation: 121

How to allow "." in @Html.Label() method

I want show label as "No. Of Student" using @Html.Label("No. of Student",new{@id="noOfStudent"}).

While executing this statement output is like: of Student

The part No. is skipped and this is due to . character.

How can I let No. be part of the output, too?

Upvotes: 0

Views: 63

Answers (1)

Marco Dal Zovo
Marco Dal Zovo

Reputation: 378

Why you didn't use a strong tipization? In your .cshtml add at start a using reference to your model (the one you passed to the View):

@model Namespace.whateveryouplacedtheclassofyourmodel

Now, you can use the model binding in your View like this:

@Html.LabelFor(m => m.property)

Then, you can add custom parameters in your model class file using metadata attributes, in this case place this piece of code above the property you wanna apply (you need to add an using to the class):

[Display(Name = "No. of Student")]

Upvotes: 1

Related Questions