我试图在用户编辑任何值时显示弹出消息,我想给出弹出提示。我正在关注这个网站寻求帮助。只有当我试图移动到其他页面时它才会调用。ii 有 ajax 选项卡页面,我想在某些 oe 移动到另一个选项卡以及离开页面时显示弹出窗口。我试过这个:
我的脚本如下所示:
<script type="text/javascript">
function PanelClick(sender, e) {
ConfirmExit();
}
function ActiveTabChanged(sender, e) {
ConfirmExit();
}
<script type="text/javascript" language="javascript">
var isDirty = false;
window.onbeforeunload = ConfirmExit;
function InputChanged(control)
{
isDirty = true;
}
function ConfirmExit()
{
if(isDirty == true){
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
}
任何形式的帮助或建议表示赞赏。
我的设计看起来像这样:
<div>
<ajaxToolkit:TabContainer runat="server" ID="Tabs" Height="150px" OnClientActiveTabChanged="ActiveTabChanged">
<ajaxToolkit:TabPanel runat="Server" ID="Panel1" HeaderText="Tab One">
<ContentTemplate>
<br />PAGE ONE - Sample HTML Content for Tab
<asp:TextBox runat="server" ID="txt1"/>
<asp:TextBox runat="server" ID="TextBox1"/>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel runat="Server" ID="Panel2" HeaderText="Tab Two" >
<ContentTemplate>
PAGE TWO - Sample HTML Content for Tab
<asp:TextBox runat="server" ID="TextBox2"/>
<asp:TextBox runat="server" ID="TextBox3"/>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel runat="Server" ID="Panel3" OnClientClick="PanelClick" HeaderText="Tab Three">
<ContentTemplate>
<BR /><BR />PAGE THREE - Sample HTML Content for Tab
<asp:TextBox runat="server" ID="TextBox4"/>
<asp:TextBox runat="server" ID="TextBox5"/>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
<br />
</div>