如何绕过表单动作?

I am trying to bypass my form action="WFMSWI.aspx" , my form is working perfectly on my system but when i am testing on server the form comes through a proprietary software which provides database and inputs the form action automatically, which i not allowing my C# code to trigger. I tried using J query ajax but in URL it cannot the method because they change the URL too, if I put anything action like action="#" they change it no matter what.What can do to bypass it and that my method triggers instead of it. i also tried using Handler but nothing is working. Everything is working perfectly in local system and in server too it doesn't show any error it just fires form action rather than my c# code.

Form Action:

<form action="WFMSWI.aspx" id="form1" runat="server"  method="post" name="form1">

Form Button:

<input type="button" ID="submit"  class="btn btn-success" value="Approve" />                
<button id="hiddenButton" runat="server" onserverclick="btnClick_Click" style="display:none;" ></button>

Java Script :

<script type="text/javascript">

    var isEmpty = function (element) {
        if ($("#" + element).val() == "" || $("#" + element).val() == null) {
            return true;
        } else {
            return false;
        }

    };

    var arrayCheck = function (array) {
        for (var i = 0; i < array.length; i++) {
            if (array[i] == false) {
                return false;
            }

        };

        return true;
    };

    function arrayAssign(array, num) {
        for (var i = 0; i < num; i++) {
            array[i] = false;

        };

        return array;
    };



    function validationCheck(array, number, element) {
        if (isEmpty(element)) {
            $("#" + element).parent(".form-group").addClass("has-error");
            array[number] = false;
        } else {
            $("#" + element).parent(".form-group").removeClass("has-error");
            array[number] = true;
        }
    };

    var pass1 = [];





    $(document).ready(function () {
        if ($.browser.msie) {
            if (parseInt($.browser.version) < "9.0") {
                alert("Sorry! This form does not support your current IE version, please use Firefox/Google Chrome to submit.");
            }
        }

        var preSig = $('#stu-sig-bit').val();
        $('#stu-sig').attr('src', preSig);
        var fakeVari = $("#typea").val();

        $("#esignature").jSignature({
            "background-color": "transparent",
            "decor-color": "transparent",
            "color": "#1489FF",
        });

        $("#clear").click(function () {
            $("#esignature").jSignature("reset");
        });



        $("input[type=text]").attr("readonly", true);
        $("textarea1").attr("readonly", true);
        //$("input[type=radio]").attr("disabled", "disabled");
        $("#reject-reason").attr("readonly", false);




        $("#submit").click(function () {


            $("#bitmap").val($("#esignature").jSignature("getData"));

            arrayAssign(pass1, 2);
            pass1[2] = false;

            validationCheck(pass1, 0, "remaining_work");
            validationCheck(pass1, 1, "deadline_date");


            pass1[2] = true;

            if (!arrayCheck(pass1)) {
                return false;
            }
            else if ($("#esignature").jSignature("getData", "native").length == 0) {
                alert("Please sign at bottom of the form.");
                return false;
            } else {
                $("#iso_sig").val($("#bitmap").val());
                $("#iso_decision").val("no");
                var date = new Date();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                var temp = (month < 10 ? "0" : "") + month + "/" + (day < 10 ? "0" : "") + day + "/" + date.getFullYear();
                $("#iso_date").val(temp);

                var answer = confirm('Are you sure you want to approve the case?');
                if (answer == true) {

                    document.getElementById('<%= hiddenButton.ClientID %>').click();


                } else {
                    return false;
                }

            }



        });


        $("#reject-button").click(function () {


            $("#bitmap").val($("#esignature").jSignature("getData"));
            if (isEmpty("reject-reason")) {
                alert("Please write down the reason why you reject the request.");
                return false;
            } else if ($("#esignature").jSignature("getData", "native").length == 0) {
                alert("Please sign at bottom of the form.");
                return false;
            } else {
                $("#iso_sig").val($("#bitmap").val());
                $("#iso_decision").val("no");
                var date = new Date();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                var temp = (month < 10 ? "0" : "") + month + "/" + (day < 10 ? "0" : "") + day + "/" + date.getFullYear();
                $("#iso_date").val(temp);

                var answer = confirm('Are you sure you want to reject the case?');
                if (answer == true) {

                } else {
                    return false;
                }

            }



        });



    });
</script>

Code Behind:

namespace HTMLtoPDF
{
  public partial class HTMLtoPDF : System.Web.UI.Page
  {

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnClick_Click(object sender, EventArgs e)
    {

        DownloadAsPDF();
    }

    public void DownloadAsPDF()
    {

    }

  }

 }
查看全部
weixin_33749242
weixin_33749242
2017/04/27 20:32
  • c#
  • asp.net
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

0个回复