0

What is the proper way to handle form processing when using a SharePoint rendering template?

In my experience, I cannot have code behind attached to my rendering template. I have seen people attach event handlers to buttons and perform form processing on that event, but this doesn't feel right to me.

Is there no place to do a traditional post back check, validate, do some magic, then save an item?

1

You can use Custom Form Templates with a custom ListFieldIterator. This way you have complete controle over how a form is rendered and you can use C# in youre code behind.

control is used to enumerate item fields for display within a form. This control is inserted in list item forms through a series of nested control templates that are defined in the DefaultTemplates.ascx file that is located in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATES\CONTROLTEMPLATES directory.

There are some nice tutorials that describe step by step how to create your own custom form using a custom ListFieldIterator to override validation, rendering, fieldordering etc

  • This is the answer. A custom rendering template with custom controls. Specifically for my answer, a custom control that extends the SaveButton. – Jonathan Eckman Jan 6 '15 at 22:14
1

It depends on what you want to do. For example the SPServices jQuery library by Marc Anderson, downloadable from CodePlex, has a multitude of commands and manipulations for forms. It's not done with server side code, but purely with jQuery.

Another option, if you have the Enterprise license, is to use InfoPath to customise list forms. InfoPath list forms cannot have code behind, either, but using the out-of-the-box InfoPath functionality you can do a lot that cannot be done with the standard list form.

  • I have explored both of those options and none will work in our case. It has to be custom C# server side form processing. – Jonathan Eckman Jan 2 '14 at 22:39
  • In that case you will need to write your own code to process a list item. – teylyn Jan 2 '14 at 22:41
  • I have the logic written, the question is where to put it. Do you have any experience with this type of processing? – Jonathan Eckman Jan 2 '14 at 22:45
  • 1
    You need to set up a development environment and then create a project in Visual Studio. I am not a developer. You may want to check out the Microsoft documentation or search this site and StackOverflow - stackoverflow.com/questions/10534202/… – teylyn Jan 2 '14 at 22:49
0

I can think of two ways through which you can perform form processing (Validations) in a SharePoint list.

  • Using event receivers. More specifically before events aka synchronous even receivers.

    A Before event occurs before the currently requested operation happens. For example, the ItemAdding event is a Before event that is raised before an item is added to a SharePoint list. Looked at another way, Before events are raised when an action occurs before SharePoint writes to the content database. This provides an opportunity for an event receiver to perform tasks before data is committed to a database. A good example of the use of Before events is performing data validation, because Before events fire prior to commitment of data. You can also use Before (or synchronous) events to cancel user actions—for example, if data validation fails.

  • Using Column validations. When creating a column for a list, you can specify the formula to validate the data in the column. You can find this in Column validation section while creating a column.
Please refer this article for more detailed information about event receivers:

http://msdn.microsoft.com/en-us/library/gg749858(v=office.14).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.