I have a usercontrol and inside the html for the usercontrol, I have the following definition for a Popup control which I am trying to access from my aspx page via javascript.
<dx:ASPxPopupControl ID="MainASPxPopupControl"
ClientInstanceName="MainASPxClientPopupControl"
runat="server"
HeaderStyle-HorizontalAlign="Left"
RenderMode="Lightweight"
AutoUpdatePosition="true"
PopupHorizontalAlign="WindowCenter"
PopupVerticalAlign="WindowCenter"
OnInit="MainASPxPopupControl_Init">
In the code-behind for the usercontrol, I have the following property so my aspx page will be able to access it:
public static object MainASPxClientPopupControl { get; set; }
In the code behind of my aspx page in the Page_load event, I have the following. This prevents the error: "The Controls collection cannot be modified because the control contains code blocks”</p>
Page.Header.DataBind();
In my JS, instead of using:
<%=
which will cause the above error, I am using:
<%#
which is a databinding expression and need for the snippet in my page_load method.
Here is where the real problem lies... I have code in a JS function on my aspx page that gets hit, but always displays that the object is null. I am simply trying to get an instance of the object (the popup control in the usercontrol) where I can use it accordingly.
var cntrl = document.getElementById('<%# BMCIS.Source.Controls.ManagerSwipe.MainASPxClientPopupControl %>');
cntrl.Show();
During debugging, the runtime code is displayed as follows:
var cntrl = document.getElementById('');
The error message given is: "Unable to get property 'Show' of undefined or null reference" which obviously means (checked during debugging) that the variable "cntrl" is null and cannot get the instance of the popup control in the user control.
How can I successfully get an instance of this control???