0

我有LogoutModel一个属性。我希望我HomeController更改此值,View然后显示此值,但它似乎不起作用。当显示注销视图时,它显示:'再见 Html.LabelFor(m => m.PreviousLoggedInUsername)'

注销型号:

public class LogoutModel
        {
            public string PreviouslyLoggedInUsername { get; set; }
        }

家庭控制器:

        public ActionResult Logout(HomeModels.LogoutModel model)
        {
            model.PreviouslyLoggedInUsername = previousLoggedIn;
            return View(model);
        }

看法:

@using Ecommerce.Models
@model HomeModels.LogoutModel
@{
    ViewBag.Title = "Logout";
    Layout = "~/Views/Shared/Master.cshtml";
}

<h2>You have been logged out.</h2>

@using (Html.BeginForm())
{
    <table>
        <tr>
            <td>
                <label>Goodbye </label>
                Html.LabelFor(m => m.PreviouslyLoggedInUsername)
            </td>
        </tr>
    </table>

}

4

1 回答 1

0

您需要@Html.LabelFor...

<table>
    <tr>
        <td>
            <label>Goodbye </label>
            @Html.LabelFor(m => m.PreviouslyLoggedInUsername)
        </td>
    </tr>
</table>

作为参考,这里是Razor 语法快速指南。

于 2013-01-14T12:08:13.207 回答