Jitendra
Jitendra

Reputation: 19

How to used MVC 3.0 Razor view?

Demo.chtml

      @if (Model.IsPersonal)
        {   
            @Html.TextBoxFor(model => model.FirstName, new { style = "width:70px;height:10px;" })
        }
        else
        {
            @Html.DisplayFor(model => model.FirstName)
             
            @Html.DisplayFor(model => model.LastName)
        }

I am used above code in MVC 3.0 razor view engine space the first name and last name but &nbps does not work please help me?

Upvotes: 1

Views: 222

Answers (1)

Tim M.
Tim M.

Reputation: 54359

One way to resolve it:

<text>&nbsp;</text>

Even though you are inside a code block, this tells the Razor engine to treat it as literal, unprocessed content.

You can also use the syntax @: &nbsp;

See also: http://weblogs.asp.net/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx

Whether or not you should actually use a non-breaking space here is a different question.

Upvotes: 3

Related Questions