Confirm postback OnClientClick button ASP.NET

后端 未结 10 1323
梦毁少年i
梦毁少年i 2020-12-01 15:47


        
10条回答
  •  Happy的楠姐
    2020-12-01 15:59

    Try this:

    function Confirm() {
        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
    
            if (confirm("Your asking")) {
                confirm_value.value = "Yes";
                document.forms[0].appendChild(confirm_value);
            }
        else {
            confirm_value.value = "No";
            document.forms[0].appendChild(confirm_value);
        }
    }
    

    In Button call function:

    
    

    In class .cs call method:

            protected void btnReprocessar_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {
    
            }
        }
    

提交回复
热议问题