While trying to open RadWindow from server side getting error as "null reference" in Javascript

1

I have created the Rad window for in the aspx page and in the button click method i have written the code for opening the radwindow in VB.Net but im getting an error and window is not opening.

radWinChCode.NavigateUrl = "buildchrcd.aspx?BU=" & strBU & "&USER=" & strChgCdUser & "&HOME=N&FROMRAD=RAD"
    radWinChCode.OnClientClose = "OnClientClose"
    radWinChCode.Title = "Enter Charge Code"
    Script = "function f(){$find(""" + radWinChCode.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)

Unhandled exception at line 48, column 14 in script block

0x800a138f - JavaScript runtime error: Unable to get property 'show' of undefined or null reference

asp.net
.net
vb.net
telerik
telerik-grid
asked on Stack Overflow Feb 18, 2019 by Vaasir Nisaar S

2 Answers

1

Makes sure that:

  • the RadWindow instance you are working with is actually added to the page

  • if you are using AJAX, make sure it participates in the response

  • the string does not contain character delimiteres like quotation marks and apostrophes that can break the string itself

answered on Stack Overflow Feb 20, 2019 by rdmptn
1

The issue is most likely due to the Visible property set to False for the RadWindow. In that case, the control does not render on the page, thus the ClientSide script is unable to get a reference to it.

Assuming the RadWindow has its Visible property set to false:

<telerik:RadWindow ID="radWinChCode" runat="server"  Height="800px" Width="1024px" Visible="false"></telerik:RadWindow>
</telerik:RadAjaxPanel>

Set the Visible property of the Window to True within the Button Click event handler:

Protected Sub RadButton1_Click(sender As Object, e As EventArgs)
    radWinChCode.Visible = True 'Make the window be rendered on the page

    radWinChCode.NavigateUrl = "buildchrcd.aspx?BU=" & strBU & "&USER=" & strChgCdUser & "&HOME=N&FROMRAD=RAD"
    radWinChCode.OnClientClose = "OnClientClose"
    radWinChCode.Title = "Enter Charge Code"
    Dim myScript = "function f(){$find(""" + radWinChCode.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", myScript, True)
End Sub
answered on Stack Overflow Aug 11, 2019 by Attila Antal

User contributions licensed under CC BY-SA 3.0