I worked on this issue recently and thought of sharing this with everyone.
In order to set form field values in SharePoint 2010, you needed to use FormContext.FieldControlCollection. This is done exactly the same way in SharePoint 2013. Except there is a minor difference – the FieldControlCollection is now null. *DOH*.
Apparently, CSR (Client Side Rendering. More on this here and here) is now doing all the work. That’s why I couldn’t execute any server side code. Since client side code was not an option for me (I needed to do some complex server side validation) – I had to get the FieldControlCollection back.
After spending some time on MSDN I found this – CSRRenderMode enumeration. Since that enumeration is under Microsoft.SharePoint.WebPartPages namespace, I started looking for a web part property named something like that. And voilà:
If I would have looked here earlier
So the next thing i needed to do – is change the value of that enum in a web part programmatically. This is done by getting the WebPart from the WebPartManager and changing the property CSRRenderMode to CSRRenderMode.ServerRender:
Notice the list.DefaultEditFormUrl this is a page where the web part is. In this case i needed to change the web part on an Edit form page.
Hope this helps!