Hi Dominic,
Make sure that the javascript which contains the code block is placed in the form element which has
runat=server attribute. If this does not help, please open a new support ticket and send a sample, fully runnable reproduction project.
All the best,
Svetlina
the Telerik team