Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Bizform Upload File Error Message Customization View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
spengelly - 8/22/2011 10:21:02 AM
   
Bizform Upload File Error Message Customization
I have created a Bizform that has a file upload field. I would like to add a custom error message instead of the default "Please enter some value" which is displayed on validation. When setting up the field in the bizform there is no ability to add a custom error message. The other field types have the ability to do this.

How would I go about customizing the error message for this field type?

User avatar
Member
Member
kentico_michal - 8/23/2011 2:23:30 AM
   
RE:Bizform Upload File Error Message Customization
Hello,

You will need to change this message directly in resource file (/CMSResources/CMS.resx):

<data name="basicform.erroremptyvalue" xml:space="preserve">
<value>Please enter some value.</value>
</data>



Best regards,
Michal Legen

User avatar
Certified Developer v7
Certified  Developer v7
spengelly - 8/23/2011 8:10:49 AM
   
RE:Bizform Upload File Error Message Customization
Isn't this error message in the resource file the generic error message that affects all bizform fields that don't have one specified? It wouldnt make sense to adjust the generic message to something like "Please select a file to upload" when this generic message affects other kinds of fields?

User avatar
Member
Member
kentico_michal - 8/23/2011 8:53:12 AM
   
RE:Bizform Upload File Error Message Customization
Hello,

Yes, you are right. I am sorry, I did not realize it.
In that case, it would be better to use an OnAfterValidate event of the BizForm control to set Text property of the error label according to your needs.

You can set the Text property to some value directly or you can create and use a new resource string:

<data name="basicform.emptyfile" xml:space="preserve">
<value>Please upload a file!</value>
</data>


Example of the OnAfterValidate event:


void viewBiz_OnAfterValidate()
{
((CMS.ExtendedControls.LocalizedLabel)viewBiz.BasicForm.FieldErrorLabels["FileField"]).Text = "Please upload a file!";
// OR
((CMS.ExtendedControls.LocalizedLabel)viewBiz.BasicForm.FieldErrorLabels["FileField"]).Text = ResHelper.GetString("basicform.emptyfile");
}


For more information about BizForm handler events, I would like to point to the following article: Bizforms customization possibilities

Best regards,
Michal Legen

User avatar
Member
Member
markcoatsworth - 2/9/2012 3:59:04 PM
   
RE:Bizform Upload File Error Message Customization
Just another quick note about this -- in some cases where you are implementing custom validation, you also need to set the label to Visible:


((CMS.ExtendedControls.LocalizedLabel)viewBiz.BasicForm.FieldErrorLabels["FieldName"]).Text = "Error Message";
((CMS.ExtendedControls.LocalizedLabel)viewBiz.BasicForm.FieldErrorLabels["FieldName"]).Visible = true;


I just spent a long time stumped on this, so I figured I'd post it in case anybody else is having the same issue.