Updating Content Types Custom Edit, View Displayforms

I spent whole day yesterday to update the custom edit forms for a content type. Well, I was writing a workflow and wanted to write custom UI for my tasks editing. There are couple of ways, using aspx forms or InfoPath. I tried to go via aspx route. To do it via aspx you need to basically create a content type for your task type and create the edit pages for the content type. When you click the task for editing, SharePoint opens the edit form for the content type. Neat! The process is well documented here.

Now the problem I was facing was that even though I specified a new task edit form aspx page, on clicking the edit link I was still getting the OOB dispform.aspx page while viewing the task. This was weird as I tried all different options including deactivate andĀ uninstalling feature. I wrote a small console app to loop through the SPContentType and see whats the props set in that. It showed that the props for editformurl and displayformurl props are still having empty string as their value. I just wrote following lines of code to update them to the urls for my custom forms and updated the content type. And it all started working fine

SPContentType ct=web.Lists["ListName"].ContentTypes["ContentTypeName"];

ct.EditFormUrl="_layouts/youreditpage.aspx";

ct.Update();

What I interpretedĀ is that deploying the task content type using feature is not properly associating the formurls with the contenttype properties.