RadWindow open issue

6 posts, 0 answers
  1. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 09 Feb 2012 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Feb 2012 Link to this post

    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.
  3. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 10 Feb 2012 Link to this post

    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;
    }

  4. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 10 Feb 2012 Link to this post

    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
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4529 posts

    Posted 13 Feb 2012 Link to this post

    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 >>
  6. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 13 Feb 2012 Link to this post

    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.
Back to Top