I've got a custom control that inherits from Panel. At Load-time, I want to access all of the controls inside of this panel, including non-server controls, to manipulate the attributes. The Controls property of the panel gives me the server controls, but not the non-server ones. Is there any way to access them?
For example:
<cc:MyPanel runat="server">
<asp:TextBox id="txt1" runat="server" />
<input type="text" id="txt2" />
</cc:MyPanel>
During the Load event (or really any event before the control is rendered), I want to manipulate both text boxes.
Thanks
You'd have to either add runat='server' on each tag or do some JavaScript to handle this.
The load event is looking at server controls.
Change your control to:
<input id="txt2" runat="server" type="text" />
Then you can do:
string s = txt2.Text;
The only other way I can think of is if you wanted to actually use a form to post the values and then use Request. to access each variable that you are posting. But my thought is you are looking more for the former rather then the latter.
Finally if you go the JS route here is a nice article from MSDN showing you how to do this: http://msdn.microsoft.com/en-us/library/3hc29e2a.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With