I have the following control on my ASPX page:
<asp:TextBox ID="txtISBN13" runat="server" ClientIDMode="Static" />
I need to access this element without referring to it explicitly. Because this control does not yet exist during the Page_Load event, I have to access it later in the Page Life Cycle.
I've tried overriding the OnUnload event, because this is the final event, but I still can't access my control by either:
Control c = new Control();
c.FindControl("txtISBN13");
Or:
Control c = Page.FindControl("txtISBN13");
Am I overriding the incorrect event? Is ClientIDMode screwing with me? Even if I try similar code on a button click event, I get no luck. Do I need some kind of recursive FindControl? Should I be using Page.FindControl or Control.FindControl?
For this situation, I am unable to do:
this.txtISBN13.Text = "Foo";
Instead, I'll have a DataColumn (previousValue), and I need to find that control and set it's value. I'm trying:
string pendingID = String.Format("txt{0}", previousValue.ColumnName);
TextBox txt = new TextBox();
txt.ID = pendingID;
txt.Text = "Foo";