1

I'm using Sitecore WebForms for Marketeers. I have created a custom field with a custom property. The custom field works fine.

I want to read the custom property when I click on the submit button, but I do not know how I can read the custom property.

In the field value is the C# parameter property, but this is null. How can I read the value of the custom property?

Relevant code:

   //Set values in dictionary
    var values = new Dictionary<String, String>();
    foreach (AdaptedControlResult field in fields)
    {
        values.Add(field.FieldName, field.Value);
    }
JoshDM
  • 4,939
  • 7
  • 43
  • 72
VRC
  • 745
  • 7
  • 16
  • What do you mean by "I want to read the custom property when I click on submit"? Do you mean that you want to read the property in the form results, or on the back-end? – Zachary Kniebel Jul 10 '13 at 14:09
  • Where did you actually add the custom property? Did you add it to the Control class that you created based on `Sitecore.Form.Web.UI.Controls....` or did you add it to the actual `WebControl` that you created to be displayed on the front-end (e.g., a `System.Web.UI.WebControls.TextBox`, etc.)? – Zachary Kniebel Jul 10 '13 at 14:20

1 Answers1

2

I wanted to read the value of custom property in a save action.
The field parameters was null because I didn't override the Result to pass the parameters.

Solution is to override the Result in your Custom Field Class.

/// <summary>
/// Override the result to get the selected value in the save action
/// </summary>
public override ControlResult Result
{
    get
    {
        return new ControlResult(this.ControlName, this.textbox.Text, MaxLeadManagerFieldName);
    }
}

The third parameter is the parameter field in the save action field property.
Fill this with the property of your custom field and you can read the parameters in your save action ;)

VRC
  • 745
  • 7
  • 16