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

RadWindow open issue

5 Answers 475 Views
Window
This is a migrated thread and some comments may be shown as answers.
GP
Top achievements
Rank 1
GP asked on 09 Feb 2012, 10:40 PM
Hi.  I keep getting the following javascript error when I try to open a radwindow: "Uncaught TypeError: Cannot call method 'open' of undefined ".  The document is in a folder, and I am trying to get to it with this url...

Here is my code:
<telerik:RadCodeBlock ID="rcb1" runat="server">
    <script type="text/javascript">
 
        function openDoc() {
            var myBox = $find("<%= RadTextBox1.ClientID %>");
            var myURL = myBox.get_value()
 
            window.radopen("Folder1\/" + myURL + ".pdf", "ViewDoc");
            return false;
        }
 
 
    </script>
</telerik:RadCodeBlock>
           
and my radWindow:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" Skin="WebBlue">
        <Windows>
            <telerik:RadWindow ID="ViewDoc" runat="server" Title="Add or Edit"
            Width="410px" Height="475px" ReloadOnShow="true" ShowContentDuringLoad="false"
            Modal="true" />
        </Windows>
</telerik:RadWindowManager>


Any help is greatly appreciated.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2012, 05:53 AM
Hello,

I tried to reproduce the problem but no avail. Make sure that the folder path is given correctly.
JS:
function OnClientClick()
 {
  var myBox = $find("<%= RadTextBox1.ClientID %>");
  var myURL = myBox.get_value();
  window.radopen("../Folder/"+myURL+".aspx", "RadWindow1");
 }

Thanks,
Princy.
0
GP
Top achievements
Rank 1
answered on 10 Feb 2012, 02:37 PM
Hi, Princy.  I fixed the URL, but I still get that javascript error "Uncaught TypeError: Cannot call method 'open' of undefined " .

I even changed the URL to try to reopen Default.aspx instead, but it didn't change the error.  I must have a typo somewhere.  

Thanks.

function OnClientClick()
{
    var myBox = $find("<%= RadTextBox1.ClientID %>");
    var myURL = myBox.get_value();
    window.radopen("../PaperlessImages/" + myURL + ".pdf", "UserListDialog");
    return false;
}

0
GP
Top achievements
Rank 1
answered on 10 Feb 2012, 03:10 PM
Ok, for some reason, the "OnClientClicked" event was firing whenever the btnView (Radbutton) was loaded...not clicked.  We ended up having to add the onclick as an attribute during the pageload event on the server. 

Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    btnView.Attributes.Add("onclick", "openDoc();return false;")
End Sub
0
Marin Bratanov
Telerik team
answered on 13 Feb 2012, 12:31 PM
Hello GP,

While this may work I suggest you simply attach the OnClientClicked handler to the RadButton properly. Like all other RadControls the handler needs only the name of the JavaScript function it will call, without the parentheses. They would cause it to execute as soon as the line is parsed, which is too early for the controls to work (they need their scripts which are loaded at a later stage). You can see examples how to attach this handler here.


Regards,
Marin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
GP
Top achievements
Rank 1
answered on 13 Feb 2012, 02:40 PM
That would explain why it kept firing whenever the control was loaded.  I took the parentheses out as you suggested, and it did work as it should.  Thank you for your help.
Tags
Window
Asked by
GP
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
GP
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or