Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Adding a custom field to the newsletter subscription webpart View modes: 
User avatar
Member
Member
paul.truman-sunmed.co - 11/16/2012 5:05:36 AM
   
Adding a custom field to the newsletter subscription webpart
Hi folks, I'd like to add a country dropdown field to the newsletter subscription webpart. Now I've cloned the webpart, added the field to the webpart and the system table, but I'm not sure what to do next in terms of the code I need to use to make it show.

Can anyone help me please??

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/17/2012 2:23:23 AM
   
RE:Adding a custom field to the newsletter subscription webpart
Hi,

If you have added the drop down list to the ASCX code of the web part - it should be displayed when viewing the page with the web part. Now, in the code behind of the web part you need to handle the values of the drop down - first of all fill it and then, on user selection and the subscription submission, you need to pass the selected value to be saved in the DB for given field you have added to the system table. You can use the SetValue("fieldName") method to save the value to given object.

Best regards,
Juraj Ondrus

User avatar
Member
Member
paul.truman-sunmed.co - 11/17/2012 11:20:41 AM
   
RE:Adding a custom field to the newsletter subscription webpart
Hey, thanks for the guidance :) I'm just a little stuck on how to populate the dropdown menu with the list of countries. Could you help me out again please? I've got the dropdown list to display, but its showing no values (I've formatted the dropdown list as a country selector in the system table).

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/20/2012 3:32:00 AM
   
RE:Adding a custom field to the newsletter subscription webpart
Hi,

You can populate the values in the code behind - just by selecting them from the CMS_Country and CMS_State tables e.g. using SQL command.

Or, you can use the form control again, register it in the ascx:

<%@ Register Src="~/CMSFormControls/CountrySelector.ascx" TagName="CountrySelector"
TagPrefix="cms" %>


and then use it:

<cms:CountrySelector ID="countrySelector" runat="server"... />


Best regards,
Juraj Ondrus