0

I have a confirmation dialog that's made using JavaScript library, I want to make it appear when the user tries to delete a row from gridview. The thing with this library is that it doesn't use confirm function in JavaScript instead it shows a custom popup, once the user clicks Yes it executes a call back function, once the user clicks No it executes another call back function.

When using this library with server side event, the server side event doesn't wait for the confirmation as it's not the javascript confirm function, so how do I make the server side code wait from a result of the call back in my JS alert if yes or no?

I am new to development in general so thanks for any ideas.

1 Answer 1

2

You'll have to bind the javascript function to be called to the OnClientClick property and OnClick will be binded to the server-side event.

In that javascript function, which will be called first, before the server-side event, you'll have to return either true or false.

If true, the server-side event will execute, if false, there won't even be a post back. Based on your comments and your plugin, you could do it like this

function sampleFunction() {
    var flag = false; // maintain a flag
    alertify.confirm("This is a confirm dialog.", function() {
        flag = true; // set it true here
    }, function(){});
    return flag; // return the flag
}
Sign up to request clarification or add additional context in comments.

18 Comments

@Richard use MY code. You've not specified the second function
It should be var tag = false; alertify.confirm(Title, function () { tag= true; }, function(){}); return tag;
@Richard I don't get you. Now do this. Go to alertifyjs.com and then paste the code - var flag = false; alertify.confirm("This is a confirm dialog.",function () { flag = true; },function () {}); alert("It works really well!!!"); alert(flag);
make a fiddle @Richard
@Richard yeah. It is sort of weird.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.