|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Finding a controlIf i have a control in a class like,
class MyPage : Page { .... protected HtmlGenericControl myCtrl; .... } How do I go about getting a reference to that control without using the name myCtrl? I tried to use the method FindControl('myCtrl'), but had no luck. Cheers, Aeden if you have this control on the page, ala:
<title id="myCtrl" runat="server" /> ASP.net will automatically hook up a reference to yoru myCtrl object in the codebehind. Alternatively, you should be able to do it with findControl, but note that this isn't recursive, so you might need to to FindControl("ParentContainer").FindControl("myCtrl") Karl Show quoteHide quote "Aeden Jameson" <AedenJame***@discussions.microsoft.com> wrote in message news:78FDCF14-F999-4085-8EE0-C09C9E35DF16@microsoft.com... > If i have a control in a class like, > > class MyPage : Page { > .... > protected HtmlGenericControl myCtrl; > .... > } > > How do I go about getting a reference to that control without using the > name > myCtrl? I tried to use the method FindControl('myCtrl'), but had no luck. > > Cheers, > Aeden "=?Utf-8?B?QWVkZW4gSmFtZXNvbg==?="
<AedenJame***@discussions.microsoft.com> wrote in Show quoteHide quote news:78FDCF14-F999-4085-8EE0-C09C9E35DF16@microsoft.com: myCtrl is your class name NOT the control name. A simple solution would be > If i have a control in a class like, > > class MyPage : Page { > .... > protected HtmlGenericControl myCtrl; > .... > } > > How do I go about getting a reference to that control without using > the name myCtrl? I tried to use the method FindControl('myCtrl'), but > had no luck. to give each myCtrl a fixed name when you create them. If you want to find a control by type, you'll have to create your own recurisve function to search the Page's control tree. -- Stan Kee (spamhoneypot@rogers.com)
Other interesting topics
maximum datagrid row count?
Pre compiling web site in 2.0 webconfig file Programmatically click asp.net button via javascript? How can I stop ASPX file rendering in Page_Load event? Help on Store procedure and ASP web page Upload if files from client PC or local network Filter Collection System.Net.WebClient.DownloadFile doesn't work with http attachments ASP.NET 2 ICallbackEventHandler |
|||||||||||||||||||||||