@using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form"}))
{
@Html.AntiForgeryToken()
<br/>
<div class="form-group">
<div class="col-md-10">
@Html.HiddenFor(m => m.Email, new {@class = "form-control"})
@Html.HiddenFor(m => m.FirstName, new {@class = "form-control"})
@Html.HiddenFor(m => m.LastName, new {@class = "form-control"})
<input type="submit" class="btn btn-default btn-lg btn-success" value="Forsæt"/>
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script>
$(".form-horizontal").submit();
</script>
}
这是我尝试的脚本的表单。我想要的是,只要调用此视图并且表单应在页面加载时自动提交。有没有办法让它像这样?甚至不去页面提交表格?
答案 0 :(得分:1)
我认为因为您的脚本在页面完全加载之前加载。尝试使用
包装您的提交操作$(document).ready(function() {
$(".form-horizontal").submit();
})