Question

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>
Was it helpful?

Solution 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.

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top