I have an asp.net page with C# code behind. In the asp page, I have a few asp Literals. As an example, I have a Literal called "ltrtitle".
<asp:Literal runat="server" ID="ltrtitle" />
In the code behind, I set the Text property of the literal to this:
<asp:TextBox runat="server" ID="title" TextMode="MultiLine" Columns="0" Rows="2" />
This renders a text box on the asp page for the user to enter text. When The user goes to save, I want to be able to get the Text value of the TextBox (Not the Literal). I have tried the following:
TextBox txtbxHiddenUser = (TextBox)FindControl("title");
Didn't Work. Tried:
foreach(Control c in Page.Form.Controls)
{
if(c.ClientID == "ltrtitle")
{
foreach (TextBox textbox in c.Controls.OfType<TextBox>())
{
TEST3456 = textbox.Text;
}
}
}
Still doesn't work. I would have thought FindControl would have worked. Any idea what I am doing wrong?