Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Error in BizForm drop-down View modes: 
User avatar
Member
Member
jonm-latinlink - 7/5/2012 5:06:48 AM
   
Error in BizForm drop-down
Hi,
We are using a BizForm for our Contact Form and there is a drop-down item for the field 'I Live In...' that contains a list of countries. The first value is 'Please choose' and you cannot submit the form without choosing a country - an error is displayed saying 'Please make a selection'. The last value is 'Other' if the country you live in isn't listed. However, when choosing this value, the same error is displayed. This isn't correct.

I am not a developer so I don't know how to fix this but the relevant code from the layout of the ContactForm webpart is below:

<li>
<cms:LocalizedLabel ID="LocalizedLabel8" runat="server" ResourceString="contact.ILivein"
AssociatedControlID="ddlCountryResidence"></cms:LocalizedLabel>
<asp:DropDownList ID="ddlCountryResidence" runat="server" AppendDataBoundItems="true"
DataTextField="Value" DataValueField="Key">
<asp:ListItem Value="0">Please choose</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlCountryResidence"
ErrorMessage="Please make a selection" ValidationGroup="contact" InitialValue="0"></asp:RequiredFieldValidator>
</li>

Please could someone tell me how to modify this so that when you select the 'Other' value in the drop-down menu, it doesn't throw up the validation error?

Thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/5/2012 3:16:19 PM
   
RE:Error in BizForm drop-down
Hi,

How is the DropDownList control filled with values? I guess it is done in the code behind. So, if I am right, you need to handle the "other" selection in code behind too to not to fire validation event - e.g. add to this selection some dummy value.

Best regards,
Juraj Ondrus

User avatar
Member
Member
jonm-latinlink - 7/6/2012 5:45:10 AM
   
RE:Error in BizForm drop-down
Thanks, I added a dummy value of 2 to the code in the ascx.cs file which had a reference to "other" and this got rid of the validation warning. So it read:

PersonCustomFields customfields = new PersonCustomFields();
Dictionary<int, string> countries = customfields.GetAllCountries();
countries.Add(2, "Other");
ddlCountryResidence.DataSource = countries;
ddlCountryResidence.DataBind();