Javascript exception when opening window for the second time

139 views Asked by At

I'm performing CRUD operations on a TelerikRadWindow, which works fine at the first time but when i try to do it a second time throws Javascript exception "Uncaught TypeError: Cannot read properties of null (reading 'show') at openRadWindow". Any ideas on what it could be? Thank you in advance!

<div class="form" runat="server" id="divUC" >
<telerik:RadWindowManager RenderMode="Lightweight" ID="radInfoWindow" runat="server" DestroyOnClose="true" CommandName="Confirmar" ShowContentDuringLoad="false" language="pt-PT">             
                <Windows>
                    <telerik:RadWindow RenderMode="Lightweight" ID="UserListDialog" runat="server" Title="Editar Timesheets" Height="400px"
                        Width="800px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" 
                        Modal="true" DestroyOnClose="true" VisibleStatusbar="False"
                        Behaviors="Close,Move,Resize" CssClass="opaque"  KeepInScreenBounds="True" AutoSize="false" 
                    >
                        <ContentTemplate>
                            <uc1:ViewEmissaoTimeSheetEdit ID="EditTimesheet" runat="server"  />
                        </ContentTemplate>
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>   

//JS function

function openRadWindow() {
        var radwindow = $find('<%=UserListDialog.ClientID %>');
       radwindow.show();
    }

//Form opening

(e.CommandName == "InitInsert") //Same for Edit
        {

            try
            {
                //UserListDialog.Dispose(); 

                string script = "function f(){openRadWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); //Open Window
            
                e.Canceled = true;

 (...) some other code to deal with creating and binding the form
                
            }
0

There are 0 answers