Read a textfield from the parentwindows

7 posts, 0 answers
  1. Christian
    Christian avatar
    97 posts
    Member since:
    Mar 2009

    Posted 28 May 2009 Link to this post

    How can I in a RadWindow read the content of a textflield from the parentwindow?

    thanks

    Christian
  2. Caroline
    Caroline avatar
    21 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    I am just trying to do this too if anyone can help..?

    I have managed to pass a hard-coded word in the URL which i can then use in my pop up window but how can i get what is typed in the textbox to go into the URL?

    heres my code:  Basically where i have typed 'smith' i need to get the value of the txtSurname textbox.

    <

     

    telerik:RadTextBox ID="txtSurname" runat="server">

     

     

    </telerik:RadTextBox>

     

    <

     

    button class="button" onclick="openRadWindow('smith'); return false;">Search</button>

     

    <

     

    script type="text/javascript">

     

     

     

     

     

    function OpenPositionedWindow(oButton, url, windowName) {

     

     

    var oWnd = window.radopen(url, windowName);

     

    }

     

    function openRadWindow(SearchCriteria) {

     

     

    var oWnd = radopen("Page.aspx?Search=" + SearchCriteria, "RadWindow1");

     

    oWnd.center();

    }

     

    </script>

    I have searched everywhere but cannot find anything to help...is it actually possible does anyone know?

    thank you

     

  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 May 2009 Link to this post

    Hi,

    Try the following approach for accessing the control in parent window from radwindow itself.

    JavaScript for page opened in Radwindow:
     
    <script type="text/javascript">  
    function GetControl()  
    {  
         //get the browser window  
         var oBrowserWnd = GetRadWindow().BrowserWindow;  
         alert(oBrowserWnd.document.form1.txtSurName.value); // 'txtSurName' is he ID of textbox in parent page 
    }  
    function GetRadWindow()  
    {  
      var oWindow = null;  
      if (window.radWindow)  
         oWindow = window.radWindow;  
      else if (window.frameElement.radWindow)  
         oWindow = window.frameElement.radWindow;  
      return oWindow;  
    }    
    </script>  

    Caroline, you can also try accessing the textbox and get the value in openRadWindow() function instead of passing as argument, and then call the method for opening the window.

    JavaScript:
     
    function openRadWindow() 
       var txt= document.getElementById("TextBox1"); 
       var SearchCriteria= txt.value; 
       var oWnd = radopen("Page.aspx?Search=" + SearchCriteria, "RadWindow1"); 
       oWnd.center(); 
    Please feel free to share the comments. :)

    -Shinu.
  4. Caroline
    Caroline avatar
    21 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    Thanks so much Shinu, just trying it now...first i have tried changing the function on the parent page to the below, but i dont think it is finding my textbox as i am getting error objective required.  any ideas?  many thanks

    function openRadWindow() 
       var txt= document.getElementById("txtSurname"); 
       var SearchCriteria= txt.value; 
       var oWnd = radopen("Page.aspx?Search=" + SearchCriteria, "RadWindow1"); 
       oWnd.center(); 

    I have also just tried putting this code in the popup page

     

     

     

    <script type="text/javascript">

     

     

     

     

     

     

    function GetControl() {

     

     

    //get the browser window

     

     

     

     

     

     

    var oBrowserWnd = GetRadWindow().BrowserWindow;

     

    alert(oBrowserWnd.document.form1.txtSurname.value);

    // 'txtSurName' is he ID of textbox in parent page

     

     

     

     

     

    }

     

    function GetRadWindow() {

     

     

    var oWindow = null;

     

     

    if (window.radWindow)

     

    oWindow = window.radWindow;

     

    else if (window.frameElement.radWindow)

     

    oWindow = window.frameElement.radWindow;

     

    return oWindow;

     

    }

     

     

    </script>

    but am getting..document.form1.txtSurname is null or not an object...

    its definately the name of my text box, i am using a RadTextBox and not a normal text box but i assume it shouldnt matter?

    thanks so much for your help on this.

     

  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 29 May 2009 Link to this post

    Hi Caroline,

    I suggest to check the following help articles that show how to work with RadTexBox:
    http://www.telerik.com/help/aspnet-ajax/input_clientsidebasics.html
    http://www.telerik.com/help/aspnet-ajax/input_clientsideradtextbox.html

    As you can see, you need to get a reference to the RadTextBox control first and then use its client-side API in order to get the value.


    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Caroline
    Caroline avatar
    21 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    thank you for pointing me in the right direction Georgi  i will take a look.

    Caroline
  7. Caroline
    Caroline avatar
    21 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    Thank you Shinu and Georgi, by combining what you both told me I have managed to get it working...it now works like this and works perfectly...thanks so much.

    function

     

    openRadWindow(SearchCriteria) {

     

     

    var txt = $find("<%= txtSurname.ClientID %>");

     

     

    var SearchCriteria = txt.get_value();

     

     

    var oWnd = radopen("Page.aspx?Search=" + SearchCriteria, "RadWindow1");

     

    oWnd.center();

     

    }

Back to Top