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

Radconfirm called by "automated" script

2 Answers 74 Views
Window
This is a migrated thread and some comments may be shown as answers.
Gianluca
Top achievements
Rank 1
Gianluca asked on 17 Apr 2009, 03:47 PM
Hi,
I'm upgrading my older version of telerik radwindow with the newest one.

I need to show radconfirm by an action on a radgrid, after postback, so I manage a label inside a hidden placeholder (called "labAlert"), and on postback i assign to "labAlert.Text" a script that calls radconfirm, and i set visible the placeholder
this is on ascx.cs:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "ActionName") 
        { 
            String ScriptJs = "<script language=JavaScript>"
            ScriptJs += "{"; 
            ScriptJs += "ShowConfirm('ConfirmText')"; 
            ScriptJs += "}"; 
            ScriptJs += "</SCRIPT>"; 
            labALERT.Text = ScriptJs
            PlaceHolder1.Visible = true
            e.Canceled = true
        } 
 

and this is on .ascx
<script type="text/javascript"
    function ShowConfirm(text) 
    { 
        radconfirm(text, confirmCallBackFn, 200, 100, '', ' '); 
        return false; 
    } 
    function confirmCallBackFn(Conferma) 
    { 
        if (Conferma) 
        { 
            [...javascrip actions if OK ...] 
        } 
        else 
        { 
           [...javascrip actions if CANCEL...] 
        } 
    } 
    </script> 

whith old version of radwindow it works fine, but with new version i get a javascript error on browser when radconfirm is called...
Where is the difference???

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2009, 07:08 AM
Hi Gianluca,

Your site is an AJAXEnabledWebSite and the page lifecycle is the lifecycle of an ajaxified page. The RadControls (ASP.NET Ajax version) as all ajax objects are rendered last on the page. Therefore you need to ensure that before the function's execution the RadWindowManager control is rendered on the page. To do this you should add a load handler and execute your function there as shown below. Give a try with this code snippet and see whether its working fine for you.

CS:
 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == "ActionName"
    { 
        labALERT.Text = "<script type='text/javascript'> Sys.Application.add_load(function(){ShowConfirm('ConfirmText');})</script>";  
        PlaceHolder1.Visible = true
        e.Canceled = true;  
    } 

Thanks,
Shinu.
0
Gianluca
Top achievements
Rank 1
answered on 20 Apr 2009, 12:29 PM
It's Perfect!!!!!
Thank-you very much!!!!
Tags
Window
Asked by
Gianluca
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Gianluca
Top achievements
Rank 1
Share this question
or