开发者

Get text value of input from FindControl

I know now normally you can get the value of a 开发者_如何学Pythontext 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.


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;
}


It has been a while since I used the controls, but i believe it is:

string text = ((TextBox)LoginView1.FindControl("txtComment")).Text;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜