0
votes

I have created a custom form control for use in my Kentico bizform using asp.net and I want to change the field caption style of another field in the form depending upon the value in my custom form control field. So, this is what I have done:

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

However, the field caption in the form doesn't seem to get bolded. I tried testing if the event even fires and it does. Infact, if I try something like formItem.Text = "Something" then the texbox gets filled with "Something". While debugging I also noticed that the field caption style does get changed to "font-weight: bold" but that doesn't show on the form. So, there is something wrong with the captionstyle property or the way I am using it. How do I get it to work?

(Please note that the field control "Other" is a text box input)

1

1 Answers

0
votes

It's probably too late in Page's lifecycle and the control has already been rendered. Try to set the CaptionStyle earlier (e.g. in control's OnLoad or OnInit) then you'll know with certainty.