在母板页中利用递归函数设置所有引用页面的值,判断类型可以用control.toString()来实现,此方法返回控件的命名空间和控件类名。
如果有更好的建议欢迎到http://www.programbbs.com讨论
protected void Page_Load(object sender, EventArgs e)
{
//初始化样式
InitControl(ContentPlaceHolder1); //ContentPlaceHolder1是母板页的容器
}
/// <summary>
/// 初始化页面控件 申国新 programbbs.com
/// </summary>
protected void InitControl(Control conMain)
{
foreach (Control c in conMain.Controls)
{
//表格
if (c.ToString().Equals("DevExpress.Web.ASPxGridView.ASPxGridView"))
{
DevExpress.Web.ASPxGridView.ASPxGridView myGrd = c as DevExpress.Web.ASPxGridView.ASPxGridView;
myGrd.CssFilePath = "~/App_Themes/Glass/{0}/styles.css";
myGrd.CssPostfix = "Glass";
}
//按钮
if (c.ToString().Equals("DevExpress.Web.ASPxEditors.ASPxButton"))
{
DevExpress.Web.ASPxEditors.ASPxButton myBtn = c as DevExpress.Web.ASPxEditors.ASPxButton;
myBtn.CssFilePath = "~/App_Themes/Glass/{0}/styles.css";
myBtn.CssPostfix = "Glass";
}
if (c.HasControls())
InitControl(c);
}
}