February 18, 2016

Read CheckboxList values in WFFM

If you use CheckBoxList in WFFM, during form submission you will receive data in XML format.  You have to deal with "CheckBoxList" fields separately to read its value.

if(field.Value.Contains("<item>"))

  {

    fieldValue = GetCommaSeperatedListValues(field.Value);

  }

 

private string GetCommaSeperatedListValues(string listValues)
        {
           
XDocument xDocumentListValues = XDocument.Parse(String.Format("<myRootNode>{0}</myRootNode>", HttpContext
.Current.Server.HtmlDecode(listValues)));
           
string commaSeperatedValues = string.Join("Specify separator here"
, xDocumentListValues.Root.Elements().Select(p => p.Value));
           
return
commaSeperatedValues;
        }


No comments:

Post a Comment