我有.Net webform的问题,需要你的帮助。我有一个js的模态调用来创建新项目。点击保存,没关系。但是,然后,我按F5,它重新提交并创建新项目相同的力量。 帮我找到解决问题的方法。非常感谢。 ////我的模态
<div id="modalCreate" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Thêm mới</h4>
</div>
<div class="modal-body">
<table>
<tr>
<td style="width: 180px; height: 45px;">Tên cơ quan ban hành <span class="requiredInput">*</span></td>
<td style="width: 300px">
<asp:TextBox CssClass="form-control" runat="server" ClientIDMode="Static" ID="txtCreateTenCoQuan"></asp:TextBox>
</td>
</tr>
<tr>
<td style="height: 45px;">Tên viết tắt</td>
<td>
<asp:TextBox CssClass="form-control" runat="server" ClientIDMode="Static" ID="txtCreateTenVietTat"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 45px;">Địa chỉ <span class="requiredInput">*</span></td>
<td>
<textarea class="form-control" runat="server" id="txtDiaChi"></textarea></td>
</tr>
<tr>
<td style="height: 45px;">Số điện thoại <span class="requiredInput">*</span></td>
<td>
<asp:TextBox CssClass="form-control" MaxLength="20" runat="server" ClientIDMode="Static" ID="txtCreateSoDienThoai"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 45px;">Email <span class="requiredInput">*</span></td>
<td>
<asp:TextBox CssClass="form-control" runat="server" ClientIDMode="Static" ID="txtCreateEmail"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 45px;">Fax</td>
<td>
<asp:TextBox CssClass="form-control" runat="server" ClientIDMode="Static" ID="txtCreateFax"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 45px;">Số thứ tự</td>
<td>
<asp:TextBox CssClass="form-control" runat="server" ClientIDMode="Static" ID="txtCreateSoThuTu"></asp:TextBox></td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Hủy</button>
<asp:Button Text="Lưu" OnClientClick="return ValidateForm()" OnClick="btnCreateLuu_Click" runat="server" ID="btnThemLuu" CssClass="btn btn-primary" />
</div>
</div>
</div>
</div>
//// js show modal
function ShowModalCreate() {
$("#modalCreate").modal()
{
show: true;
return false;
}
return;
}
////最后代码
protected void btnCreateLuu_Click(object sender, EventArgs e)
{
try
{
var entity = new EDMCoQuanBanHanh();
entity.TenCoQuan = txtCreateTenCoQuan.Text.Trim();
entity.TenVietTat = txtCreateTenVietTat.Text.Trim();
entity.DiaChi = txtDiaChi.InnerText;
entity.SoDienThoai = txtCreateSoDienThoai.Text.Trim();
entity.Email = txtCreateEmail.Text.Trim();
entity.Fax = txtCreateFax.Text.Trim();
entity.SoThuTu = Convert.ToInt16(txtCreateSoThuTu.Text);
BDMCoQuanBanHanh.Insert(entity);
txtCreateTenCoQuan.Text = string.Empty;
}
catch (Exception ex)
{
WriteLog.WriteLogEntry("CoQuanBanHanh - btnCreateLuu_Click()", ex);
}
}