0

I have built a selection of ASP.net controls on my default.aspx page. I am using the following line of javascript to try and get the value of an ASP control.

var imgUrl = document.getElementById("<%= backUrl.ClientID %>").value;

However this throws up the following error when I try to run my app on SP.

Sorry, there was a problem with bannerSlide. For support, please contact the developer. An error occurred during the processing of /sites/dev/bannerSlide/Pages/test.aspx. Code blocks are not allowed in this file.

Most online solutions seem to point towards modifying a web file but I don't think this is possible with SharePoint Online (Office 365).

Any help would be greatly appreciated, thanks.

2

Default.aspx is a Site Page and inline C# or VB code is not allowed in Site Pages. So you need to replace the code block (i.e. <%= backUrl.ClientID %>) with the literal id of the element.

| improve this answer | |
  • You can use inline code even in site pages as long as the page is not customized, e.g. it has been deployed through a farm solution package. As soon as you edit it in Designer it will break. Still, this is no help to Ben for SP Online. – Louis Sep 26 '13 at 0:10

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.