Problem with dropdown menu in XForms?

Vote:
 

Hi,

I have tried searching for a solutions to my problem, but didn't really find anything relevant, so please forgive me if this has already been asked (and answered).

I have an XForm on a page, with a couple of fields. One of them is a dropdown menu, where the value of each item indicates where to send the generated email after submission.

In code behind I generate an email message (in an event handler attached to the XFormControl.BeforeSubmitPostedData event) containing the heading (not the name) and the value of each field, using e.FormData.GetValues().

My problem is that this works great for all fields, except for the dropdown menu. In this case it returns a comma separated list of the values of all the items in the dropdown menu, which means I have no idea which item was actually selected.

Has anyone ever had this problem before, and possibly a solution?

Regards,

/Paddy

#43060
Sep 10, 2010 16:21
Vote:
 

Hi Patrik!

Have you found a solution to your problem? I tried to reproduce the problem but it works fine for me. The logic in GetValues() is pretty simple if you want to dig deeper yourself:

            NameValueCollection values = new NameValueCollection();

            foreach (XmlNode node in Data.DocumentElement.ChildNodes)
                values.Add(node.Name, node.InnerText);

            return values;
Regards
Linus Ekström
EPiServer Development Team
#43111
Sep 14, 2010 12:37
Vote:
 

Thank you for your reply!

I think I have a solution.

I've done some further testing. It seems that if two or more items in the dropdown menu have the same value, and I select either of those and then submit the form, the value of the field is all the identical values concatenated into the same string with a comma separating them.

Realizing this, I can just split on "," and take the first value, ignoring the rest.

#43707
Sep 21, 2010 18:45
Vote:
 

It would be nice if I could mark my own replies as an answer :)

#43708
Sep 21, 2010 18:47
Vote:
 

Hi!

Thanks for the additional info and I'm glad that you found a work around. I have filed this as a bug since I don't think that this behaviour is desired.

Regards
Linus Ekström
EPiServer Development Team

#43718
Sep 22, 2010 10:40
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.