Thursday, August 8, 2013

SharePoint RenderingTemplate Gotcha!

Recently when working on a SharePoint 2010 project I let a minor mistake cause a great deal of frustration. I was creating a custom field that used a custom rendering template. I have done this before, but I guess on this day my mind was in WebForms land and I ended up with a solution that would deploy, but when I went to access my custom field, it would not render.

Here is a picture of my template… can you see the problem?


I had included the button OnClick call in the control markup. If you do this, your template will not render because it does not know how to wire up that event to it’s respective event handler. Take note of the Control declaration. Unlike normal ASP.Net User Controls, there is no reference to a Code Behind or Inherited Type… therefore… any events that need to be wired up will have to be done in your RenderingTemplateControl class file, and not in the markup!

I hope this helps!

No comments:

Post a Comment