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

[Solved] Read a textfield from the parentwindows

6 Answers 196 Views
Window
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 28 May 2009, 03:10 PM
How can I in a RadWindow read the content of a textflield from the parentwindow?

thanks

Christian

6 Answers, 1 is accepted

Sort by
0
Caroline
Top achievements
Rank 1
answered on 29 May 2009, 10:53 AM
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

 

0
Shinu
Top achievements
Rank 2
answered on 29 May 2009, 11:47 AM
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.
0
Caroline
Top achievements
Rank 1
answered on 29 May 2009, 12:58 PM
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.

 

0
Georgi Tunev
Telerik team
answered on 29 May 2009, 01:57 PM
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.
0
Caroline
Top achievements
Rank 1
answered on 29 May 2009, 02:00 PM
thank you for pointing me in the right direction Georgi  i will take a look.

Caroline
0
Caroline
Top achievements
Rank 1
answered on 29 May 2009, 02:42 PM
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();

 

}

Tags
Window
Asked by
Christian
Top achievements
Rank 1
Answers by
Caroline
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Georgi Tunev
Telerik team
Share this question
or