Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Using One Country Selector Control For Two Separate Fields View modes: 
User avatar
Member
Member
bassem.mf-gmail - 6/18/2012 5:10:55 AM
   
Using One Country Selector Control For Two Separate Fields
Hello,

If I have a Document Type / Custom Table with two fields: CountryID and StateID. Is it possible to use one country selector control to specify the value for these two fields? I do not want the editor to have to enter IDs in text boxes. I need an interface just like the interface for creating a new customer in CMS Desk.

Thanks in advance!

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/18/2012 1:07:17 PM
   
RE:Using One Country Selector Control For Two Separate Fields
Hi,

When using the default country selector there is only one field needed. However, if you need to two fields, you will need to develop a custom form control to achieve your goal.

Best regards,
Juraj Ondrus

User avatar
Member
Member
bassem.mf-gmail - 6/18/2012 1:25:58 PM
   
RE:Using One Country Selector Control For Two Separate Fields
Thank you for your response!

How can I create a custom form control that is used to edit 2 separate fields? I want this control to be used by the editor in the CMS Desk.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/19/2012 6:20:10 PM
   
RE:Using One Country Selector Control For Two Separate Fields
Hi,

This is fully up to you. You need to create a form control which will have e.g. two fields and it will save the values into two separate DB columns according to your needs.

Best regards,
Juraj Ondrus

User avatar
Member
Member
bassem.mf-gmail - 6/19/2012 8:28:05 PM
   
RE:Using One Country Selector Control For Two Separate Fields
But how can I do that?

When you define the document type / custom table fields it asks you to select the form control for each field separately.

And the form control has a single property called Value to provide the value selected by the user.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/20/2012 1:09:30 PM
   
RE:Using One Country Selector Control For Two Separate Fields
Hi,

you will have two fields. One will be using your custom form control and the other will be e.g. a text box. The custom form control will save the value to its respective field as well as to the other field specified as a text box. That is my idea - it is fully up to you how you will design it.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 6/20/2012 4:03:15 PM
   
RE:Using One Country Selector Control For Two Separate Fields
There is also a method called GetOtherValues that you can override. Add a settings field to your custom form control of something like "StateFieldName" so you can tell it what field to set the state value for and then do something like this:

public override object[,] GetOtherValues()
{
if (!String.IsNullOrEmpty(StateFieldName))
{
object[,] result = new object[1, 2];
result[0, 0] = StateFieldName;
result[0, 1] = selectedStateName; //this is the variable that you will need to set to your selected state name.
return result;
}
else
{
return base.GetOtherValues();
}
}


User avatar
Member
Member
bassem.mf-gmail - 6/20/2012 4:36:36 PM
   
RE:Using One Country Selector Control For Two Separate Fields
Thanks a lot Juraj and Jiveabillion for your suggestions.