Design and CSS styles
Version 6.x > Design and CSS styles > FieldInfo.CaptionStyle not working on custom form control View modes: 
User avatar
Member
Member
Somashree - 5/29/2012 10:56:22 AM
   
FieldInfo.CaptionStyle not working on custom form control
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.Value = "Something" then the texbox gets filled with "Something". 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 and I have defined Value as a Property that gets the value selected in the drop down list)

User avatar
Member
Member
kentico_michal - 5/31/2012 10:04:54 PM
   
RE:FieldInfo.CaptionStyle not working on custom form control
Hi,

Please try to use the following code to change the style of field caption:

LocalizedLabel formItem = (LocalizedLabel)this.Form.FieldLabels["Other"];
formItem.Attributes.Add("style", "font-weight:bold");

Best regards,
Michal Legen