【发布时间】:2012-07-12 15:13:16
【问题描述】:
我能够获取页面所有控件的 ID 以及它们的类型,当我打印它时在页面中显示
myPhoneExtTxt Type:System.Web.UI.HtmlControls.HtmlInputText
这是根据这段代码生成的
foreach (Control c in page)
{
if (c.ID != null)
{
controlList.Add(c.ID +" Type:"+ c.GetType());
}
}
但是现在我需要检查它的类型并访问其中的文本,如果它的类型是 HtmlInput 并且我不太确定该怎么做。
喜欢
if(c.GetType() == (some htmlInput))
{
some htmlInput.Text = "This should be the new text";
}
我该怎么做,我想你明白了吗?
【问题讨论】:
标签: c# asp.net interface casting