cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Fields using ASP.NET

Custom Fields using ASP.NET

Hi,

 

I'm trying to create a signup form with a few custom fields, but when I submit the form the contact gets created but none of the custom fields get saved to the contact.

 

Here's a snippet of my code I'm using in the code behind to save the custom field, am I missing something or doing something wrong?

 

if (!string.IsNullOrWhiteSpace(txtCustomfield.text)) {
    var customfield1 = new CustomField();
    customfield1.Name = "CustomField1";
    customfield1.Value = pAffected.Value;
    contact.CustomFields[0] = customfield1;
}
1 REPLY 1
Highlighted
Honored Contributor

Re: Custom Fields using ASP.NET

Hello,

 

Based on just that snippet of code, it looks like that should work. While it should be functionally the same, I would suggest the following code to assign the custom field:

contact.CustomFields.add(customfield1);

Is it possible to share a larger snippet showing some of the logic for how you create and submit the contact data? (Please note that you'll want to censor your API key and access token from any code snippets that you share)

 

Sincerely,

Elijah G.
API Support Engineer