0

I have an asp.net page in which I have a ckeditor control and ajax file upload tool. I want to show user certain message when he tries to leave the page without saving data.I am beginner in JavaScript/JQuery and would like to find some easy solution directly implemented into asp.net code.If possible can you provide step by step implementation of dirty bit functionality.

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

Above code shows me the message even if nothing has changed on the page.How do I apply it to specific control like ckeditor/ajaxuploadctrl etc

Below is the HTML code

<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>
ROY
  • 33
  • 12
  • 1
    What you tried .. so far?? – Moumit May 24 '16 at 10:08
  • I tried dirty bit with javascript functionality but no message was displayed.I also tried suggestion mentioned in this post but it didn't work for me.below is the link http://stackoverflow.com/questions/155739/detecting-unsaved-changes – ROY May 24 '16 at 10:29
  • Stack-overflow helps you on anything you have done but not working in proper-way .. no body might not like to write the whole code for you .. so i would like to suggest you to share the code of the best solution you found .. and try to make it proper by taking others help .. – Moumit May 24 '16 at 12:29
  • Please at least show your HTML code (or your ASP.NET code that generates the HTML). [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) makes this completely automatic (in many cases) and [has a module for CKEditor](https://github.com/NightOwl888/jquery.dirtyforms.helpers.ckeditor.dist#readme), but without seeing your markup code or understanding *what* form elements you want dirty checking on, it is difficult to provide an example that will be helpful to you. Also, provide the name of the AJAX file upload tool (if you want the file upload control checked for dirtyness). – NightOwl888 May 24 '16 at 17:37
  • I have added the JavaScript code above which works irrespective of any changes done to the page.How will I check if any changes are done to ckeditor/ajax file upload?? – ROY May 25 '16 at 05:05

0 Answers0