Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a drop down with "Create New" option. If user clicks "Create New" option then popup window will display with save button. In that popup window, user will enter data and after user will save this data on server.

And passing that script like this,
ASP.NET
<button runat="server" id="Savefile" class="btn btn-primary" onclick="savefile()";


When user clicks "Save" button then data has to store in that given path. but it is not performing any action. And it is closing automatically when I click "Save" button. Can you please help me to solve this problem.

Any wrong in this code?

What I have tried:

This is jQuery function for save the data in a popup.
JavaScript
<script type = "text/javascript" >
  function savefile() {

    $(document).ready(function() {
      $('#Savefile').click(function() {
        $.ajax({
          url: 'D:\C#.Net\Scramble.txt',
          datatype: "json",
          method: 'post',
          data : scrtabledata,
          success: function() {
            var scrtabledata = $('#modaltable'); //Table ID
            scrtabledata.empty();
            $(data).each(function() {
              scrtabledata.append('<table><tbody><tr><td>' + scrtabledata.comment + '</td><td>' + scrtabledata.DropDownList2 + '</td><td>' + scrtabledata.DropDownList1 + '</td></tr></tbody></table>');
            });
          }
        });
      });
    });
  }; 
</script>

This is the code for jQuery popup:
JavaScript
<script type="text/javascript">
$(function () {
        //Attach click event to your Dropdownlist
        $("#<%= DropDownConfigFile.ClientID %>").change(function () {
            //Get the selected valu of dropdownlist
            selection = $(this).val();
            //If its one then show the dialog window. You can change this condition as per your need
            if (selection == 1) {
                //Show the modal window
                $('#myModal').modal('show');

            }
        });
    });
</script>
Posted
v3

1 solution

You have mixed it. Modify it like below.
JavaScript
function savefile() {
    $.ajax({
      url: 'D:\C#.Net\Scramble.txt',
      datatype: "json",
      method: 'post',
      data : scrtabledata,
      success: function() {
        var scrtabledata = $('#modaltable'); //Table ID
        scrtabledata.empty();
        $(data).each(function() {
          scrtabledata.append('<table><tbody><tr><td>' + scrtabledata.comment + '</td><td>' + scrtabledata.DropDownList2 + '</td><td>' + scrtabledata.DropDownList1 + '</td></tr></tbody></table>');
        });
      }
   });
}; 
 
Share this answer
 
Comments
Member 12490696 29-Apr-16 3:08am    
I have tried with your piece of code. But it is not working. any other options please.
Please debug. Not working is not enough to help you. Also check the developer console (F12). If there are any errors listed, then you need to rectify them as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900