문제

I have an input as count named in a repeater with hdncount hidden input. And I have a server side button out of repeater. This script runs onblur event of count. I want to trigger server side button's click event if client click OK button on confirmation. What should I do to do that?

<script type="text/javascript">

        function changeItemCount(input) {
            var hdnCount = $(input).closest("div").find("input[id=hdnCount]").val();
            var crrCount = $(input).closest("div").find("input[id=count]").val();

            if (hdnCount != crrCount) {
                var answer = confirm("Ürün adedi değiştirilecektir. Onaylıyor musunuz?");
                return answer;
            } else {
                return true;
            }
        }
    </script>
도움이 되었습니까?

해결책 2

Use OnClientClick together with OnClick

<asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_Click" OnClientClick="return CheckGoJSEvents();" />

EDIT:

Didn't see that you had the function execute on the blur event. In that case you would not use the OnClientClick of the button. The answer posted by mattmanser would be correct.

If you wanted it to function from the button click, then you could use this method. Sorry for the confusion.

다른 팁

How to fire a button click event from JavaScript in ASP.NET

var answer = confirm("Ürün adedi değiştirilecektir. Onaylıyor musunuz?");

if(answer)
  __doPostBack('btnSubmit','OnClick'); //use the server-side ID of the control here
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top