JavaScript: How to reference user control inside content page?
-
Hi, I use ASP.NET. This is structure I have: Master page -> Content page -> User control -> Telerik grid with its context menu, hidden field. This means: Master page contains content page, content page contains user control, user control contains Telerik grid with its context menu and hidden field. I open popup window by clicking option in Telerik grid's context menu. After I choose some option in combo box in that popup window I press OK and close it. But I don't know how to reference opener that should be user control with Telerik grid and hidden field. I want to set hidden field to some value. This is JavaScript code I use:
function ReturnValue() { var choice = document.getElementById("DropDownList1").value; if ((window.opener != null) && (!window.opener.closed)) { window.opener.document.getElementById("HiddenField1").value = choice; } window.close(); }
But, it fails on this line because opener is master page: window.opener.document.getElementById("HiddenField1").value = choice; So, how can I make it work? Thank you in advance.
-
Hi, I use ASP.NET. This is structure I have: Master page -> Content page -> User control -> Telerik grid with its context menu, hidden field. This means: Master page contains content page, content page contains user control, user control contains Telerik grid with its context menu and hidden field. I open popup window by clicking option in Telerik grid's context menu. After I choose some option in combo box in that popup window I press OK and close it. But I don't know how to reference opener that should be user control with Telerik grid and hidden field. I want to set hidden field to some value. This is JavaScript code I use:
function ReturnValue() { var choice = document.getElementById("DropDownList1").value; if ((window.opener != null) && (!window.opener.closed)) { window.opener.document.getElementById("HiddenField1").value = choice; } window.close(); }
But, it fails on this line because opener is master page: window.opener.document.getElementById("HiddenField1").value = choice; So, how can I make it work? Thank you in advance.
If you want to reference a control that is in a usercontrol from master. look at this example:
window.opener.document.getElementById('<%=ContentPlaceHolder1.FindControl("usercontrolID").FindControl("hiddenfield").ClientID %>').value = choice;
I could be wrong, but it wont hurt if you try it out.
-
Hi, I use ASP.NET. This is structure I have: Master page -> Content page -> User control -> Telerik grid with its context menu, hidden field. This means: Master page contains content page, content page contains user control, user control contains Telerik grid with its context menu and hidden field. I open popup window by clicking option in Telerik grid's context menu. After I choose some option in combo box in that popup window I press OK and close it. But I don't know how to reference opener that should be user control with Telerik grid and hidden field. I want to set hidden field to some value. This is JavaScript code I use:
function ReturnValue() { var choice = document.getElementById("DropDownList1").value; if ((window.opener != null) && (!window.opener.closed)) { window.opener.document.getElementById("HiddenField1").value = choice; } window.close(); }
But, it fails on this line because opener is master page: window.opener.document.getElementById("HiddenField1").value = choice; So, how can I make it work? Thank you in advance.
-
Hi, I use ASP.NET. This is structure I have: Master page -> Content page -> User control -> Telerik grid with its context menu, hidden field. This means: Master page contains content page, content page contains user control, user control contains Telerik grid with its context menu and hidden field. I open popup window by clicking option in Telerik grid's context menu. After I choose some option in combo box in that popup window I press OK and close it. But I don't know how to reference opener that should be user control with Telerik grid and hidden field. I want to set hidden field to some value. This is JavaScript code I use:
function ReturnValue() { var choice = document.getElementById("DropDownList1").value; if ((window.opener != null) && (!window.opener.closed)) { window.opener.document.getElementById("HiddenField1").value = choice; } window.close(); }
But, it fails on this line because opener is master page: window.opener.document.getElementById("HiddenField1").value = choice; So, how can I make it work? Thank you in advance.
Represents an open window in the browser. Members Table The following table lists the members exposed by the window object. Click a tab on the left to choose the type of member you want to view. Attributes/Properties Show: Attributes/Properties Collections Events Methods Objects Property Description closed Retrieves whether the referenced window is closed. defaultStatus Sets or retrieves the default message displayed in the status bar at the bottom of the window. dialogArguments Retrieves the variable or array of variables passed into the modal dialog window. dialogHeight Sets or retrieves the height of the modal dialog window. dialogLeft Sets or retrieves the left coordinate of the modal dialog window. dialogTop Sets or retrieves the top coordinate of the modal dialog window. dialogWidth Sets or retrieves the width of the modal dialog window. frameElement Retrieves the frame or iframe object that is hosting the window in the parent document. length Sets or retrieves the number of objects in a collection. name Sets or retrieves a value that indicates the window name. offscreenBuffering Sets or retrieves whether objects are drawn offscreen before being made visible to the user. opener Sets or retrieves a reference to the window that created the current window. parent Retrieves the parent of the window in the object hierarchy. returnValue Sets or retrieves the value returned from the modal dialog window. screenLeft Retrieves the x-coordinate of the upper left-hand corner of the browser's client area, relative to the upper left-hand corner of the screen. screenTop Retrieves the y-coordinate of the top corner of the browser's client area, relative to the top corner of the screen. self Retrieves a reference to the current window or frame. status Sets or retrieves the message in the status bar at the bottom of the window. top Retrieves the topmost ancestor window. Attributes/Properties Collections Collection Description frames Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. Events Event Description onactivate Fires when the object is set as the active element. onafterprint Fires on the object immediately after its associated document prints or previews for printing. onbeforedeactivate Fires immediately before the activeElement is changed from the current object to another object in the parent document. onbeforeprint