c# - find a control in current page -


hello, problem can't seem find control current page. page class has following code:

        <div class="meeting_body_actions">                  <efv:viewmeetingactions id="viewmeetingactions" runat="server" />         </div> 

my control has:

<%@ control language="c#" autoeventwireup="true" codebehind="viewmeetingactions.ascx.cs" inherits="efv.controls.viewmeetingactions" %> <%@ register assembly="telerik.web.ui" namespace="telerik.web.ui" tagprefix="telerik" %>  telerik:radlistbox runat="server"  cssclass="radlistbox" id="listbox_action_member" width="125" height="200px" skin="telerik" ontransferring="actionlistboxviewer_transferring" ondeleting="actionlistboxviewer_deleting" >          <buttonsettings areaheight="30" position="bottom" horizontalalign="center" />           <headertemplate>                        </headertemplate>         <items>         </items>       <footertemplate>           <asp:dropdownlist runat="server" id="action_member_dropdown"  height="22" width="125"  ></asp:dropdownlist>         </footertemplate>     </telerik:radlistbox 

from other control need throw information in "action_member_dropdown";

  control control = this.page.findcontrol("viewmeetingactions");   -> doesnt work          page page = httpcontext.current.handler page;         control viewmeetingactions = page.findcontrol("viewmeetingactions");         -> didnt work  page test = this.parent.page; -> no succes 

if ask page how many controls have says have 1 control, , added more 5.

so in short, how call control same page other control?

if control nested inside other controls, need find recursively.

here helper method. searches control recursively.

helper method

public static control findcontrolrecursive(control root, string id) {    if (root.id == id)       return root;     return root.controls.cast<control>()       .select(c => findcontrolrecursive(c, id))       .firstordefault(c => c != null); } 

usage

var mycontrol =  (mycontrol)findcontrolrecursive(page, "viewmeetingactions");  

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -