0

我有一个asp.net 页面,其中有一个ckeditor 控件和ajax 文件上传工具。当他试图离开页面而不保存数据时,我想向用户显示某些消息。我是 JavaScript/JQuery 的初学者,想找到一些直接实现到 asp.net 代码中的简单解决方案。如果可能的话,你能提供一步一步的实现吗脏位功能。

 `<script>
 window.onbeforeunload = function (e) {
 return 'Dialog text here.';
  };
</script>`

即使页面上没有任何更改,上面的代码也会向我显示消息。如何将其应用于特定控件,如 ckeditor/ajaxuploadctrl 等

下面是HTML代码

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="DirtyBit">
    <form id="form" runat="server">

       Country : <asp:DropDownList ID="drpCountry" runat="server"></asp:DropDownList>
        <br />
    <table style="width: 100%; height: 337px;">
        <tr>
            <td class="auto-style2">TV&nbsp; :</td>
            <td class="auto-style3"> <CKEditor:CKEditorControl ID="CKTV" BasePath="/ckeditor/" runat="server"
   </CKEditor:CKEditorControl>&nbsp;</td>
        </tr>
       
        <tr>
            <td class="auto-style6">BV :</td>
            <td class="auto-style7"> <CKEditor:CKEditorControl ID="CKBV" BasePath="/ckeditor/"  runat="server">
   </CKEditor:CKEditorControl></td>
        </tr>
       
        <tr>
            <td class="auto-style8">CA :</td>
            <td class="auto-style9"> <CKEditor:CKEditorControl ID="CKCA" BasePath="/ckeditor/" runat="server">
   </CKEditor:CKEditorControl></td>
        </tr>
       
        <tr>
            <td class="auto-style10">CJ :</td>
            <td class="auto-style11"> <CKEditor:CKEditorControl ID="CKCJ" BasePath="/ckeditor/"  runat="server">
   </CKEditor:CKEditorControl></td>
        </tr>
       <tr>
           <td class="auto-style1">
               Visa Form :</td>
           <td><table id="attachedfiles">
               <tr>
                   <td class="auto-style12">
       <asp:ScriptManager runat="server">
</asp:ScriptManager>
<asp:AjaxFileUpload ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="5" 
    Width="400px" OnUploadComplete="OnUploadComplete" />
                   </td>
               </tr>
               </table></td>
       </tr>
       <tr>
           <td class="auto-style4">
               </td>
           <td class="auto-style5">
               <asp:Button ID="btnSave" runat="server" Height="30px" OnClick="btnSave_Click" Text="Save" Width="109px" />
                 
           </td>
       </tr>
       <tr>
           <td class="auto-style4">
               &nbsp;</td>
           <td class="auto-style5">
               &nbsp;</td>
       </tr>
    </table>
      
    </form>
        </div>
</asp:Content>

4

0 回答 0