This is a migrated thread and some comments may be shown as answers.

passing variables into the radConfirm callBack function

2 Answers 353 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 24 May 2011, 08:06 PM
Hi,

My problem is very simple. When I deleted a user from my grid, I want to call radConfirm (from RadAjaxManager) from the serverside and send some info to the callback js function, but I don't know how to pass variables into the radConfirm. I found this trick, but it only work if my radConfirm call come from a Js function, Like I said, my call come from the serverside. So, I tried to call a Js function from the serverside with the following code :

             string script = "<script language='javascript'> " +       
                                   "    jsFunction(" + myVar + ");" +
                                   "</script>";  
            
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script ", script );

This seem to work, except that if I make a Telerik instruction in the jsFunction (like radconfirm), it doesn't work (Chrome's java
console said that I can't call radConfirm from undefined). 


So, may someone help me? How may I do it ?
Thank you

David

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 May 2011, 10:38 AM
Hello Shinu,

Try calling the function like this.
C#:
  string radalertscript = "<script language='javascript'>function f(){callRadConfirm('" + myVar + "'); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
Javascript:
function callRadConfirm(param)
  {
         function callbackFn()
        {
            alert(param);
        }
        radconfirm("sure?", callbackFn);
    }

Also take a look at the following help document.
Executing JavaScript function from server-side code

Thanks,
Shinu.
0
David
Top achievements
Rank 1
answered on 25 May 2011, 02:33 PM
Thank you

It works very well 
Tags
Ajax
Asked by
David
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or