Last post Mar 23, 2015 05:45 PM by JohnBert
Mar 09, 2015 10:55 AM|narayana karnati|LINK
I have a panel in Custom Web server Control. The panel is dynamically loaded with child controls. So I am unable to access the child controls(dynamically generated) of panel through controlscollection property.
It is alway showing '0' count when I try to acces child controls of panel. Could you please help on how access dynamically generated controls of panel in User control.
Mar 09, 2015 11:08 AM|AidyF|LINK
Mar 09, 2015 11:19 AM|narayana karnati|LINK
I have the User Control in web application. I am able to find the other controls which are created in CreateChildControls(). But unable to find the dynamically added controls.
By the below code, only the controls in panel are always 'null' .
if (key !=
Control oCtrl = Page.FindControl(key);
if (oCtrl !=
Mar 09, 2015 11:30 AM|AidyF|LINK
Is this after a postback? Are you re-creating the dynamic controls on each postback? Controls you add yourself have to be re-added on each postback, they don't survive themselves.
Mar 09, 2015 11:42 AM|narayana karnati|LINK
Ok. I am sure on how to recreate the dynamic controls on each postback. As a Custom User Control, I which method I can recreate the dynmic controls. Could you please share some sample code on it....
Mar 09, 2015 11:50 AM|AidyF|LINK
Mar 23, 2015 05:45 PM|JohnBert|LINK
You can use id selector, since the ClientIDMode for radio button is not static you will have to use ClientID as the id generated by asp.net is not what you see as a server id.
rbrbtnEn = document.getElementById(('<%= rbtnEn.ClientID %>');
To get the checked status
alert(document.getElementById('<%= rbtnEn.ClientID %>').checked);