6 Answers, 1 is accepted
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
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(); |
| } |
-Shinu.
| 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.
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.
Caroline
function
openRadWindow(SearchCriteria) {
var txt = $find("<%= txtSurname.ClientID %>");
var SearchCriteria = txt.get_value();
var oWnd = radopen("Page.aspx?Search=" + SearchCriteria, "RadWindow1");
oWnd.center();
}