Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > Open RadWin with a parameter
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Open RadWin with a parameter

Feed from this thread
  • Tiffany Phan avatar

    Posted on May 13, 2011 (permalink)

    Hello there,

    I tried to validate a parameter to make sure the ID is not null or not = 0 (zero) before I open a RadWindow.  Somehow, it displayed an alert message, but it did not open a Radwindow with the information I passed.  Here are my code, please tell me what I missed:

    the following code is for adding a "print preview" button on my RadScheduler:

    <script type="text/javascript">        
                function pageLoad()
                    {
                        var $ = $telerik.$;
                        $(" <li><a onclick='openRadWin(); return false;'><span>Print Preview</span></a></li>").appendTo($('.rsHeader ul'));
                    }

        </script>
    ______________________________________________________________________________

    this is my RadWindowManager:

     <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" ShowContentDuringLoad="false" Width="1050px"
                    Height="710px" Title="Individual Calendar" Behaviors="Default" VisibleStatusbar="False"
                    Modal="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    ______________________________________
    this is a javascript code to validate id=RecordNum before I open a RadWindow:

        <table style="width: 100%;">
            <tr>
                <td id="DecoratedControlsContainer">

                    <script type="text/javascript">
                         //   <![CDATA[
                            function openRadWin(id)                        
                            {                          
                                
                                if (!id==0)                           
                                {                              
                                    window.radopen("IndividualCalendar.aspx?RecordNum=" + id, "RadWindow1");                                 
                                }
                                else
                                {                          
                                     alert("Please select an individual name!");
                                }                                 
                             }             

                       //     ]]>                                                                        
                    </script>

                </td>
            </tr>
        </table>

    Thanks so much!

    Tiffany Phan

  • Marin Bratanov Marin Bratanov admin's avatar

    Posted on May 17, 2011 (permalink)

    Hello Tiffany,

    You do not pass a variable/value to the openRadWin() function and thus the id variable inside will be undefined, which in turn means that you will always enter the else statement and receive the alert.

    What I can suggest is that you create a global variable that you modify according to your custom logic and pass it as an argument to the function when you create the li node.

    For your convenience I created and attached a simple page illustrating the approach. Please note that I do not have your whole code, so I moved the client script to the click of a button, but that should not make a difference. I also enabled the statusbar so that you can see the entire url with the query string. You can find a video from my experiment on the following link: http://screencast.com/t/YwPmyAkH1Ev. I hope that this is the desired functionality.



    Greetings,
    Marin
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  • Tiffany Phan avatar

    Posted on May 17, 2011 (permalink)

    <script type="text/javascript">        
                function pageLoad() 
                    
                        var $ = $telerik.$; 
                        $(" <li><a onclick='openRadWin(recnum); return false;'><span>Print Preview</span></a></li>").appendTo($('.rsHeader ul')); 
                    
      
        </script>
    .
    .
    .
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" ShowContentDuringLoad="false" Width="1050px"
                    Height="710px" Title="Individual Calendar" Behaviors="Default" VisibleStatusbar="true"
                    Modal="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
        <table style="width: 100%;">
            <tr>
                <td id="DecoratedControlsContainer">
      
                    <script type="text/javascript">
                         //   <![CDATA[
                            var recnum = Session("RecordNum");
                            function openRadWin(id)                        
                            {
                                if (!id == 0)
                                {
                                    window.radopen("IndividualCalendar.aspx?RecordNum=" + id, "RadWindow1");                              
                                }
                                else
                                {
                                    alert("Please select an individual name");
                                     
                                }                               
                            }             
      
                       //     ]]>                                                                        
                    </script>
      
                </td>
            </tr>
        </table>
    Hi Marin,

    Thanks so much for your response.

    Attached is the picture of my Radschedule with a combobox on top to let an user select an individual name which is fed by RecordNum.  This value is an integer, and I got this from Session, whenever a user selects a name from the drop-down box, I capture the RecordNum of that person.

    I pasted the code of my default.aspx page here with your suggestion.  But it is still not working, alert message kept showing.
    I don't know what I did wrong.

    Please help!

    Thanks,

    Tiffany Phan

  • Marin Bratanov Marin Bratanov admin's avatar

    Posted on May 18, 2011 (permalink)

    Hello Tiffany,

    This code runs as expected on my end. You can find my test page attached and here is a video from this test: http://screencast.com/t/w3g1oz8iVr.

    The changes I had to make were:

    1. create a sample scheduler so that I can run your code
    2. hardcode a value to the recnum variable, since I do not have your custom logic

    This leads me to believe that the most probable cause for this behavior is that the recnum variable is still null or undefined and thus the issue originates in the logic that populates it.

    What I can suggest at this point to either debug this issue on your end, or open a support ticket and send us a sample, runnable project that isolates this case so that we can debug it locally and pinpoint the cause.



    All the best,
    Marin
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

  • Tiffany Phan avatar

    Posted on May 18, 2011 (permalink)

    Hi Marin,

    Finally, it works!

    The reason is that I got wrong format for Session("RecordNum") in my client side. 
    When I found the syntax Session in Javascript code, it went smoothly.

    Thank you so much,  I appreciate!

    Tiffany Phan

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Window > Open RadWin with a parameter