【问题标题】:FieldInfo.CaptionStyle in custom form control not working自定义表单控件中的 FieldInfo.CaptionStyle 不起作用
【发布时间】:2012-05-28 23:43:41
【问题描述】:

我使用 asp.net 创建了一个自定义表单控件,用于在我的 Kentico bizform 中使用,我想根据自定义表单控件字段中的值更改表单中另一个字段的字段标题样式。所以,这就是我所做的:

protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
   if(this.Value == "1")
   {
       FormEngineUserControl formItem = (FormEngineUserControl)this.Form.FieldControls["Other"];
       formItem.FieldInfo.CaptionStyle = "font-weight:bold";
   }
}

但是,表单中的字段标题似乎没有加粗。我尝试测试事件是否会触发并且确实会触发。事实上,如果我尝试像 formItem.Text = "Something" 之类的东西,那么 texbox 就会充满“Something”。在调试时,我还注意到字段标题样式确实更改为“字体粗细:粗体”,但这并没有显示在表单上。所以,captionstyle 属性或我使用它的方式有问题。如何让它工作?

(请注意,字段控件“Other”是文本框输入)

【问题讨论】:

    标签: c# asp.net .net content-management-system kentico


    【解决方案1】:

    在 Page 的生命周期中可能为时已晚,并且控件已经呈现。尝试更早地设置 CaptionStyle(例如在控件的 OnLoad 或 OnInit 中),然后您就可以确定了。

    【讨论】:

      猜你喜欢
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-18
      • 2019-12-26
      相关资源
      最近更新 更多