简体   繁体   中英

doPostBack function issue with scriptresource.axd

i worked on a page that performing simple db queries , insert,update,delete
i use .netframework 4 and sql server 2008 r2 and the page contains only one update panel
the scenario is as following:
user select a row from gridview and then decide what he want to do (update,delete)
when he click delete button a confirmation modal shows to him , if he said yes then i dopostback

           $('#btnExaminationDelete').click(function (e) {
            e.preventDefault();
            $('#modal-1').modal('show');
            $('#modal-1 #btnConfirm').click(function () {
             __doPostBack('btnExaminationDelete', '');
            });
        });

the problem: when he execute this operation for fist time its ok and no problem if he execute this operation for the second time an error occurs in the scriptresource.axd file line 6979 you can see it in firebug's console window

              if (isFileUploadRequest) {
                  xhr.send(arguments[0]);
                }
                 else {
                 xhr.send(body);  //this is line 6979
                } 


if he continue to do the same operation the error appears more than once
i don't know what exactly the cause of problem but i think its fault of __doPostBack function
this problem occurs in many pages of mine and the page hangs
is there another way to post back from jquery or javascript without __doPostBack function
what is the solution for this problem

Instead of calling __doPostBack directly, can you try to submit a form? with all the required parameters in that form?

 $('#btnExaminationDelete').click(function (e) {
            e.preventDefault();
            $('#modal-1').modal('show');
            $('#modal-1 #btnConfirm').click(function () {
$("#aform #type").val('update');
$("#aform #selected-ids").val('1,2,3');
             $("#aForm").submit();
            });
        });

finally i found up the solution simply you have to unbind the Burton before you use click function the code will be like this

     $('#btnExaminationDelete').unbind("click").bind("click",function (e) {
        e.preventDefault();
        $('#modal-1').modal('show');
        $('#modal-1 #btnConfirm').unbind("click").bind("click",function () {
         __doPostBack('btnExaminationDelete', '');
        });
     });

hoping that clear and useful for you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM