Click here to Skip to main content
15,894,297 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We recently moved from Sitecore 7.2 to 9.0.2 and since then we have started getting following error when we try to add a control(by clicking "Add here") with datasource from the experience editor. This is only happening on the 9.0.2 instance of Sitecore. Ours is not a MVC project. Just simple web forms. This happens on clicking either the first or the second Add here on the page. We are not referencing Prototype.js in the project so not sure if putting jQuery into No-conflict mode will help. Also, we are able to add controls with datasource by going to presentation details of the page in Sitecore. Any help is greatly appreciated.

Below are the screenshots of the error I am getting.

https://i.stack.imgur.com/LmhE5.png[^]

And the error in JS

https://i.stack.imgur.com/uItNp.png[^]

What I have tried:

We are not referencing Prototype.js in the project so not sure if putting jQuery into No-conflict mode will help. Also, we are able to add controls with datasource by going to presentation details of the page in Sitecore.
I also tried to create a new control(rendering) but it did not help.
Adding/removing allowed controls of the placeholder also did not help.
Posted
Updated 25-Mar-19 4:41am
v2
Comments
Richard MacCutchan 21-Mar-19 5:26am    
You probably need to contact Sitecore tech support.
F-ES Sitecore 21-Mar-19 6:55am    
The way I normally help diagnose these issues is to create a completely basic layout with just an html and body section with a placeholder, create a new rendering with just something like "Hello world" in it, then see if you can add the basic rendering to your basic layout. If that doesn't work then there is something fundamentally wrong with your Sitecore solution (did you go from 7 to 8 and then 9?) If that does work but it doesn't work on your own pages then something you are adding to the page (custom js or custom js library) is interfering with the js that Sitecore is adding. If that is the case remove your custom scripts bit by bit and when it starts working the last thing you removed is probably the issue.
Rooney (Deepak Bisht) 21-Mar-19 8:20am    
Thanks for the reply. Yes, we did move from 7 to 8 and then 9 in the current upgrade. Someone at work tried basic layout with basic rendering and said it worked. I will try it too and confirm.
I tried removing all JS references from the layout one by one and it did not help sadly.
F-ES Sitecore 21-Mar-19 9:08am    
If the basic layout works but not your page then it has to be something on your page. It might not be the js, it could also be invalid markup such as you've opened a tag but not closed it so try running the page output through an html validator. Other than that it's just a case of methodically removing things until you find out what has broken it.

1 solution

Thanks everyone for your comments and help. The issue was that in Sitecore 9, when a user adds a control on a page using the Experience Editor, on the final add button click (after providing a datasource) is treated as a POST event. In Sitecore 7.2, it was a GET request.

We had some code written in our backend (.cs file) which was looking to see if it a POST type of request and if yes, redirect to a different page. Like below.

if (Request.HttpMethod == "POST")
{
//redirect to a different page
}

I added a check here to only run this code when user is NOT in Experience Editor mode like below.

if (Request.HttpMethod == "POST" && !Repository.IsUserEditting())
{
//redirect to a different page
}

This fixed the issue. Thanks again. Let me know if anyone has any questions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900