【发布时间】:2018-11-27 15:56:22
【问题描述】:
我在 bootsrap 模式中有一个表单。当我单击提交时,它会发布数据并隐藏模式。伟大的!但是,如果我单击具有 data-dismiss 属性的取消按钮,它也会提交表单。我尝试了显式 type="button" 但它仍然提交表单。我希望“取消”按钮只关闭模式而不进行回发。有什么建议吗?
<div Class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div Class="modal-dialog" role="document">
<div Class="modal-content">
<div Class="modal-header">
<h4 Class="modal-title">Change User</h4>
</div>
<div Class="modal-body">
@If Model.impersonate.isAllowed Or Model.isAdmin Then
@<form action='@Url.Action("Parent")' id="frmChangeUser" method="post">
@If Model.isAdmin Then
@<Label Class="lbl">Enter RACF Or EIN</Label>
@Html.EditorFor(Function(m) Model.userRacf, New With {.class = "form-control"})
Else
@<Label Class="lbl">Select an Operator</Label>
@<select id="select" class="form-control" onchange="$("#userRacf").val($(this).val());">
@For Each item In Model.impersonate.AccessList
@<option value="@item.Value.ToString">@item.Text.ToString</option>
Next
</select>
@<input type="text" id="userRacf" name="userRacf"/>
End If
<div Class="modal-footer">
<Button Class="btn-green" type="submit" id="getUser">Get</button>
<Button Class="btn-grey" type="button" data-dismiss>Cancel</button>
</div>
</form>
Else
@<label>You are not currently registered for impersonation, to request access fill out form on homepage</label>
@<Button Class="btn-grey" data-dissmiss="modal">OK</button>
End If
</div>
</div>
</div>
</div>
【问题讨论】:
标签: asp.net-mvc vb.net razor bootstrap-modal