我在更新面板中有一个 asp.net 复选框,其中 autopostback 设置为 true。当我选中复选框时,它会显示我想要显示的其他控件。当我取消选中该复选框时,数据库中的值会更新。这一切都很好。
如果我想在取消选中复选框后移动到另一个页面,则会显示一个对话框,询问我是要留在该页面上还是离开该页面。如何阻止该对话框出现?
<asp:UpdatePanel runat="server" ID="upOnProbation" UpdateMode="Conditional">
<ContentTemplate>
<div>
<table>
<tr>
<td>
<asp:CheckBox runat="server" Text="On Probation" ID="chkOnProbation" AutoPostBack="true" ClientIDMode="AutoID" />
</td>
</tr>
<asp:PlaceHolder runat="server" ID="plcProbabtionDates" Visible="false">
<tr>
<td>
Start date
</td>
<td>
<ComponentArt:Calendar runat="server" ID="dtStart" ControlType="Picker" PickerFormat="Short">
</ComponentArt:Calendar>
</td>
</tr>
<tr>
<td>
End date
</td>
<td>
<ComponentArt:Calendar runat="server" ID="dtEnd" ControlType="Picker" PickerFormat="Short">
</ComponentArt:Calendar>
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btnSave" Text="Save" CssClass="btn" />
</td>
</tr>
</asp:PlaceHolder>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub chkOnProbation_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkOnProbation.CheckedChanged
If chkOnProbation.Checked Then
plcProbabtionDates.Visible = True
dtStart.SelectedDate = DateTime.Now
dtEnd.SelectedDate = DateTime.Now.AddMonths(6)
Else
plcProbabtionDates.Visible = False
objCompany.On_Probation = False
objCompany.Save(UserStaffID)
End If
End Sub