gpt4 book ai didi

c# - 替换为 Html.BeginForm()

转载 作者:太空宇宙 更新时间:2023-11-03 21:38:10 24 4
gpt4 key购买 nike

我正在使用 Bootstrap 在我的 MVC 4 应用程序中创建登录 View 。它正在工作,但这是我的登录 View :

@using (Html.BeginForm())
{
<link href="~/Content/dist/css/signin.css" rel="stylesheet">
<div class="container">
<form class="form-signin" role="form">
<h2 class="form-signin-heading">Entrar</h2>
<input type="text" id="User" name="UserName" class="form-control" placeholder="Usuário" required />
<input type="password" id="Pass" name="Password" class="form-control" placeholder="Senha" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
</form>
</div>
}

但 css 的引用是 'link href="~/Content/dist/css/signin.css"rel="stylesheet' 行,但它只有在我删除@Html.BeginForm(),但是当我创建一个 HttpPost 时我无法触发我的操作。

如何在没有 Html.BeginForm() 的情况下调用我的操作?

最佳答案

我现在可以看到您在 eachother 中使用了两种形式。您应该删除 Bootstrap 并确保 BeginForm 发出正确的形式:

    <link href="~/Content/dist/css/signin.css" rel="stylesheet">
<div class="container">
@using (Html.BeginForm("your-action", "your-controller",
FormMethod.Post,
new { @class="form-signin", role = "form} ))
{
<h2 class="form-signin-heading">Entrar</h2>
<input type="text" id="User" name="UserName" class="form-control" placeholder="Usuário" required />
<input type="password" id="Pass" name="Password" class="form-control" placeholder="Senha" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
}
</div>

关于c# - 替换为 Html.BeginForm(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20693222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com