Hi everybody, I hope someone of you can give a hand. I will post some sample code however they are pretty much what I am trying to do.
I have a button which executes both client side (OnClientClicking) and server side (OnClick) events. The point is that from the client side I execute a PageMethod in order to get the result of a calculation. Up to this point everything is OK but here comes the tricky part.
I need to check for the result in order to determine if it is greater than some value. If this condition is true then I ask the user to confirm if he wishes to continue, so if the user says YES then the code continues executing OnClick event but if user says NO then OnClick must not be executed.
I have tried passing teleriks args as a parameter but it is not working (OnSuccess function receives it as null). I do this in order to call args.set_cancel() method.
Here is the code at client side
01.
function
btnCallback_Clicking(sender,args)
02.
{
03.
var
num = parseInt( prompt(
"Enter an integer number"
,
"1"
) );
04.
05.
PageMethods.multiply(num,
function
(response, args){ TheSuccess(response, args); });
06.
}
07.
08.
function
TheSuccess(response, args)
09.
{
10.
//alert(' TheSuccess: \nResult obtained was: ' + response);
11.
if
(response > 70) {
12.
var
cancel = !confirm(
"Result obtained was greater than 70 ¿Continue?"
);
13.
args.set_cancel(cancel);
14.
}
15.
}
Here is the code at server side
01.
[System.Web.Services.WebMethod]
02.
public
static
int
multiply(
int
num)
03.
{
04.
int
res = num * num;
05.
return
res;
06.
}
07.
08.
protected
void
btnCallback_Click(
object
sender, EventArgs e)
09.
{
10.
string
extra =
"User agreed to do this"
;
11.
btnCallback.Text = extra;
12.
}
Any ideas about how to achieve this.
Thanks in advance.