foreach(Control control in this.Controls)
{
if(contorl is TextBox)
{
.....
}
}
不过因为Control可能会有Child Control,所以你要在这边做递归.
{
if(contorl is TextBox)
{
.....
}
}
不过因为Control可能会有Child Control,所以你要在这边做递归.
解决方案 »
- 关于正则表达式控制问题
- |M| 如何用DataGrid的页脚绑定我的Allmoney字段
- 请教大家一个关于GridView显示的问题
- 50分请,较好的用asp.net(c#)的招聘方面的项目
- ASP.NET调用API问题,请高手指导
- DataGrid问题!没分了,希望能帮我一下!
- iis6发布网站 更改.NET Framework版本问题
- 请教一个关于单点登录的概念问题
- 以下的连接 mdb 数据库的连接字串怎么写呀
- 用response.redict()可以在新窗口中打开吗
- 怎样让ASP.NET支持Access数据库中的中文表名?
- asp.net中用aspnet_regiis -i ,执行的过程中没有任何反映,已经等了很久了。怎么办?
{
if (ctrl is TextBox)
{
....
}
}
你看看可不可以
{
if (control is TextBox)
{
...
}
}
{
if (control is TextBox)
{
...
}
}记住一定是Controls[1] 才是窗体上所有控件的集合
{
SetCultrueInfo( parentCtrl );
SetCssClassInfo( parentCtrl ); if ( !parentCtrl.HasControls() ) return; foreach ( Control ctrl in parentCtrl.Controls )
{
VisitSubControls( ctrl );
}
} private void SetCultrueInfo( Control ctrl )
{
string strValue = ""; try
{
if ( ctrl is Button )
{
if ( ctrl is ButtonBase )
{
ButtonBase curCtrlBase = ( ButtonBase )ctrl;
strValue = rmResxMan.GetString( PageName + "."+curCtrlBase.ID+".AlertText" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrlBase.AlertText = strValue;
strValue = rmResxMan.GetString( PageName + "."+curCtrlBase.ID+".ConfirmText" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrlBase.ConfirmText = strValue;
if ( isRecordCtrlText )
{
RecordCtrlText( dsWebFormCtrl, PageName, curCtrlBase.ID+".AlertText" ,curCtrlBase.AlertText );
RecordCtrlText( dsWebFormCtrl, PageName, curCtrlBase.ID+".ConfirmText" ,curCtrlBase.ConfirmText );
}
}
Button curCtrl = ( Button )ctrl;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".Text" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.Text = strValue;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".ToolTip" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.ToolTip = strValue;
if ( isRecordCtrlText )
{
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".Text" ,curCtrl.Text );
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".ToolTip" ,curCtrl.ToolTip );
}
}
else if ( ctrl is CheckBox )
{
CheckBox curCtrl = ( CheckBox )ctrl;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".Text" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.Text = strValue;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".ToolTip" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.ToolTip = strValue;
if ( isRecordCtrlText )
{
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".Text" ,curCtrl.Text );
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".ToolTip" ,curCtrl.ToolTip );
}
}
else if ( ctrl is DataGrid )
{
}
... ...
else if ( ctrl is TextBox )
{
TextBox curCtrl = ( TextBox )ctrl;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".Text" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.Text = strValue;
strValue = rmResxMan.GetString( PageName + "."+curCtrl.ID+".ToolTip" );
if ( strValue != null && strValue.Trim().Length > 0 ) curCtrl.ToolTip = strValue;
if ( isRecordCtrlText )
{
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".Text" ,curCtrl.Text );
RecordCtrlText( dsWebFormCtrl, PageName, curCtrl.ID+".ToolTip" ,curCtrl.ToolTip );
}
} }
catch( Exception )
{
} return;
}
我还没试不过相信你
正确!