我在我的 asp net mvc 应用程序中有这个表单,在表单上方检查发布的字段。他们中有几个失踪了。无法理解为什么
<form id="FormRegistroUsuario" action="/Account/AdminSecurityUserAccountAdd">
<fieldset>
<legend><h2 style="color:black;">Cadastro novo Usuário</h2></legend>
<table id="tblUsuario">
<tr>
<td class="smallField">Username:</td>
<td>@Html.TextBoxFor(m => m.UserName,new { @class = "validate[required]" }) </td>
<td class="smallField" style="padding-left:10px;">Email:</td>
<td>@Html.TextBoxFor(m => m.Email, new { @class = "validate[required,custom[email]]" }) </td>
<td style="padding-left:10px;">Ativo:</td>
<td>@Html.CheckBoxFor(m => m.Active)</td>
</tr>
<tr>
<td class="smallField">Senha:</td>
<td>@Html.PasswordFor(m => m.Password, new { @class = "validate[required, minSize[7]]" }) </td>
<td style="padding-left:10px;">Repetir Senha:</td>
<td>@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "validate[required,equals[Password]]" }) </td>
<td style="font-size:10px; padding-left:10px;">Habilitar Login com Cert. Digital:</td>
<td>@Html.CheckBoxFor(m => m.isCertifiedAdd)
<div id="certDigitalBlockAdd">
<table>
<tr>
<td class="smallField">Tipo do Certificado:</td>
<td>@Html.DropDownListFor(m => m.certTypeAdd, new SelectList(Model.certTypeComboBox, "id", "type"), "Escolha...", new { @class="smallField" })</td>
<td style="display:none;">@Html.Hidden("certTypeAddHidden")</td>
</tr>
<tr>
<td>Identificação:</td>
<td>@Html.TextBoxFor(m => m.identifierAdd, new { @class = "validate[required] smallField" })</td>
<td style="display:none;">@Html.Hidden("identifierAddHidden")</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td class="smallField">Pergunta Secreta:</td>
<td>@Html.TextBoxFor(m => m.SecretQuestion, new { @class = "validate[required]" }) </td>
<td style="padding-left:10px;">Resposta:</td>
<td>@Html.TextBoxFor(m => m.SecretQuestionPassword, new { @class = "validate[required, minSize[6]]" }) </td>
<td></td>
<td></td>
</tr>
</table>
<br />
<div class="scrollTable" style="margin-left:20px;">
<span class="boxTitle"><table><tr><td>Grupos Disponíveis</td></tr></table></span>
<!-- Tipos -->
<div class="scroller">
<table>
<!-- Indices Disponíveis (Exibidos) -->
@{
counter = 1;
}
@foreach (var role in Model.roles)
{
<tr id="@counter" class="whiteRow setIndex">
<td class="adminTipoFormRowIndex">@role</td>
</tr>
counter++;
}
</table>
</div>
</div>
<div class="scrollTable" style="margin-left:60px;">
<span class="boxTitle"><table><tr><td>Grupos Atribuidos</td></tr></table></span>
<!-- Tipos -->
<div class="scroller scrollerindex">
<table>
@{
counter = 1;
}
@foreach (var role in Model.roles)
{
string count = counter + "_a";
string inputCount = counter + "_i";
<tr id="@count" class="whiteRow unsetIndex" style="display:none;">
<td class="adminTipoFormRowIndex">@role</td>
<input type="hidden" id="@inputCo**strong text**unt" name="rolesGroup" value="@role" disabled="disabled"/>
</tr>
counter++;
}
</table>
</div>
</div>
<input type="submit" value="Salvar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-link submitAddTipo"/>
</fieldset>
</form>
JS:
$('#FormRegistroUsuario').submit(function (e) {
e.preventDefault();
var form = $(this);
console.log(form.serialize());
});
已发布的字段:
UserName=Guilherme
Email=grlongo.ireland%40gmail.com
Active=true
Active=false
Password=%23t1g2p3&
ConfirmPassword=%23t1g2p3&
isCertifiedAdd=true
isCertifiedAdd=false
SecretQuestion=Qual+a+senha%3F&
SecretQuestionPassword=secreta
rolesGroup=Administrador
不管我使用@Ajax.beginForm 还是这种方法,结果都是一样的。
- 使用 Ajax.beginForm 发送
- 和ajax提交句柄
- 创建隐藏的附加隐藏字段以检查它们是否会被发布(并且不会)。
非常感谢您的任何帮助。