Using jquery to post values back to an asp.net webform. I have some code that works great for sticking posted Form values into my object, basically it converts the form values into the correct type for each property in my class.
if (Request.Form.HasKeys())
{
foreach (var key in Request.Form.AllKeys)
{
PropertyInfo itemProperty = _CmsItem.GetType().GetProperty(key, BindingFlags.Public | BindingFlags.Instance);
var value = Request.Form[key];
if (itemProperty != null)
{
itemProperty.SetValue(_CmsItem, Convert.ChangeType(value, itemProperty.PropertyType), null);
}
}
// Doing some processing with my object
}
Now I have run into a quandary on how to handle a string like MyKeys = 123,13332,232323 and get that into an array or list in my object. What would be the best way to handle this situation?
Clarification: I have built the page to handle regular form posts as well as $ajax callback posts based on a requestmode flag so the page / or parts of the page can be re-used based on different circumstances.