SharePoint 2013 - ListFieldIterator Save issue

Background Stories:

I need to customize List Item New Form to arrange my fields. I also need to auto generate the fields if user create their own field in the List. I decided to create my own List Definition and create my own NewForm.aspx associate to the List Definition.

In my NewForm.aspx, my requirement is to hard-code those fields predefined in the List Definition and combine new fields created into the List. Thus, I decided to use ListFieldIterator control to generate those new fields that not in my NewForm.
ListFieldIterator is very intellegent because it will not auto generate the fields if you have created elsewhere(must be before the ListFieldIterator control) in the aspx page.

Below is the result that I want.
See my xml:

Problem
When click on [Save] button, the "Title" field is NOT save into my list. I notice that when I look at Fiddle, it called the Client.svc and it will not post back to my current aspx page.

 Title field is Empty.



When click Save, Fiddle is showing a call to Client.svc.



Title field is not in the parameter that post to the Client.svc


Solution:
What we can do is instead of relying on SharePoint Save button, we overwrite the save button. In the Code-Behind of the NewForm.aspx, we just need to add the following in Page_OnInit event: Delegate the save handler to our own custom save handler.

Once the above code is in place, you can save your items into your List where all the fields are save.

You can download the sample code from here

Disclaimer: This post is for my own knowledge base. You can use it anyway you want to and I am not responsible if anything happen.

Comments

Popular posts from this blog

SharePoint 2013: Distributed Cache Services

SharePoint 2013 for Developer: Baby Journey (1)

File Structure (Part 1)