小编Phi*_*ers的帖子

按钮水平内联文本框Razor View

我在视图上有以下表格

@using (Html.BeginForm("AddInterest", "Club", FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        <hr />
        <div class="row">
            <div class="col-md-8">
                <div class="well bs-component">
                    <div class="form-group">
                        <div class="col-md-10 col-md-offset-1">
                            <h3>Not listed? - Add extras here</h3>
                        </div>
                    </div>
                    @Html.HiddenFor(model => model.ClubTypeId)
                    @Html.HiddenFor(model => model.ClubId)
                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                    <div class="form-group">
                        <div class="row col-md-offset-1 col-md-11">
                            <div class="col-md-4">
                                @Html.LabelFor(model => model.InterestName, htmlAttributes: new { @class = "control-label" })
                                @Html.EditorFor(model => model.InterestName, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.InterestName, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc razor twitter-bootstrap-3

2
推荐指数
1
解决办法
7872
查看次数

在 for 循环剃刀视图中分组

我的剃刀视图中有以下内容

                @foreach (var group in Model.QuestionList.GroupBy(x => x.AreaName))
            {
                <h4>@group.Key</h4>

                for (int i = 0; i < Model.QuestionList.Count(x => x.AreaName == group.Key); i++)
                {

                <div class="form-group">
                    <div class="row">
                        <div class="col-md-4">
                            @Html.DisplayFor(x => Model.QuestionList[i].Question)
                        </div>
                        <div class="col-md-2">
                            @Html.HiddenFor(x => Model.QuestionList[i].StnAssureQuestionId)
                            @Html.DropDownListFor(model => model.QuestionList[i].Score, new SelectList(Model.QuestionList[i].Scores, "ScoreId", "ScoreNum", 0), "Please Select", new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.QuestionList[i].Score, "", new { @class = "text-danger" })
                        </div>
                        <div class="col-md-4">
                            @Html.EditorFor(x => Model.QuestionList[i].Comments, new { htmlAttributes = new { @class = "form-control" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc razor

2
推荐指数
1
解决办法
4299
查看次数

如果列表视图控制器方法中的语句

我在我的控制器方法中有以下代码,用于向成员类型的列表视图提供数据:

[HttpGet]
public ActionResult SelectMembershipType(int clubId)
    {
        //Populate the list
        var membershipTypes = from s in db.MembershipTypes
                              where (s.ClubId == clubId  && s.Dormant == false)
                              orderby s.Type
                              select s;

        //Generate the ViewModel with the appropriate membership types
        var viewModel = membershipTypes.Select(t => new   SelectMembershipTypeViewModel
        {
            //Select appropriate Cost based on current month
            if(DateTime.Now.Month == t.ReducedMonth)
            {
                Cost = t.ReducedCost;
            }
            else
            {
                Cost = t.Cost;
            }
            ClubId = club.ClubId,
            Name = club.Name,              
            MembershipName = t.Type,
            MembershipType = t.MembershipTypeClassification.Type,
            MembershipTypeId = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

0
推荐指数
1
解决办法
59
查看次数

标签 统计

asp.net-mvc ×3

c# ×3

razor ×2

twitter-bootstrap-3 ×1