0

下面是我的注册表剃须刀页面

<div class="reg-panels">
    <div class="container-rim">
        <div class="row-fluid clearfix">
            <div class="col-md-12">
                <h2>
                    Please enter your account information
                </h2>
                <div class="register-accounts">
                    <h3>
                        @strMemTypeText Membership - @strMemPlanText
                    </h3>
                    @using (Html.BeginForm())
                     {
                        <table>
                            <tr>
                                <td class="FormLeft" width="200px">
                                    <span class="mandtry">* </span>Username:
                                </td>
                                <td class="FormRight">
                                    @Html.TextBoxFor(u => u.UserName, new { @class = "form-control", @Placeholder = "UserName", @onkeypress = "return AvoidSpace(event)" })
                                    @Html.ValidationMessageFor(u => u.UserName, "", new { @class = "red" })
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input type="submit" class="btn" id="btnProceed" value="Proceed"/>
                                </td>
                            </tr>
                        </table>

                     }
                </div>
            </div>
        </div>
    </div>
</div>

我的控制器.cs

[HttpPost]
public ActionResult RegisterStep(Company company)
{
    .....
}

当我单击继续按钮时,没有执行任何操作。我也尝试使用@using (Html.BeginForm("Action","controller", FormMethod.Post))

4

2 回答 2

1

这是一个演示,您需要确保您的控制器名称和操作名称是正确的:

看法:

@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
    <table>
        <tr>
            <td class="FormLeft" width="200px">
                <span class="mandtry">* </span>Username:
            </td>
            <td class="FormRight">
                <input name="username" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" class="btn" id="btnProceed" value="Proceed" />
            </td>
        </tr>
    </table>

}

家庭控制器:

public IActionResult Index(string username)
        {
            return View();
        }

如果您不工作,您的控制台或网络中是否有任何错误消息? 在此处输入图像描述

于 2020-09-17T07:53:50.910 回答
1

您的代码看起来不错,但您可以检查

  1. 验证部分,如果您清除了所需的验证字符串。而你试图传递空数据。
  2. 打开开发者控制台并检查控制台部分是否有任何错误。
  3. 从占位符和 javascript 事件调用中删除“@”(不确定)
于 2020-09-17T08:04:25.410 回答