Get text value of input from FindControl

asp.net, c#

Solution

Try casting that `Control` to `TextBox`. `FindControl` returns a `Control` which doesn't have the `Text` property

TextBox txtName = LoginView1.FindControl("txtComment") as TextBox;
if (txtName != null)
{
    return txtName.Value;
}

Problem

I know now normally you can get the value of a text input using the following: ``` txtName.Text ``` But because my input is inside of a LoginView I am using FindControl like this: ``` LoginView1.FindControl("txtComment") ``` This successfully find the text input but returns its type rather than the value. Adding the Text function at the end does not work.

Original source