May 2013 » 6 Things to Check if your Web Part is Not Working in Kentico CMS
May 25

6 Things to Check if your Web Part is Not Working in Kentico CMS

Introduction

Have you ever had your Shopping Cart web part not get past step two in the checkout process? Or ever had your Logon Form web part not authenticate correctly. Maybe your Comment View web part doesn’t allow you to edit or add a Blog Post comment ? There is nothing more frustrating to a Kentico developer than spending time on a problem that should not be a problem.

Most developers that have experience with Kentico have probably added hundreds of web parts to web part zones in their careers. 99.9% of the time they just work the way they should. However, every once in awhile something goes wrong, and when it does, it can be infuriating. I have put together the following list below to hopefully save even the most grizzled Kentico veteran some time when it comes to troubleshooting why a web part refuses to work the way it should.

 

1. Check the Disable View State Property on Web Parts, Web Part Zones and Page Place Holders

The first place to start troubleshooting a web part that does not work is this property. Having the Disable view state checkbox checked could be the culprit for the malfunction. View state is a very important property for any ASP.Net Control to work correctly. I mention this frequently that you should turn this checkbox on during optimization of read only or listing web parts, but don't shoot yourself in the foot when it comes to controls that have PostBacks in play. ASP.Net User Controls that utilize Buttons, LinkButtons, Dropdowns with AutoPostBack set to true, and even Update Panels all require view state to work. View state is the mechanism that persists state across a PostBack so that the ASP.NET framework knows what values the controls have in them. So make sure this is not checked on the web part, the web part zone, and the page placeholder on your page template if the web part utilizes a PostBack like the Shopping Cart web part does.

 

Kentico CMS Web Part Zone Properties

 

 

2. Temporarily Disable Content Inheritance on the Page Template

The majority of Page Templates in Kentico CMS are set to inherit content from the Master Page only. If you are working through an issue of a web part or set of web parts not working, one thing to narrow down is if the issue is originating from your Page Template or the Master Page Template.

On the Template sub tab there is the Inherit content radio button list (bottom of the screen shot below). Change this to Do not inherit any content to narrow down if the problem is within your template of the master page. Just remember to change it back to what it was originally set to. Just don’t be shocked when none or just part of your CSS or JS load. This is normal when you are not inherited any content.

 

Kentico CMS Page Template Inheritance

 

 

3. Check the Transformation Code

Sometimes the problem is not within the loading of the data into a web part, rather it’s how that data is being rendered to the page. This is the job of the Transformation. Not every single web part utilizes a Transformation but for the ones that do, especially Repeaters, this can be the source of the problem. Transformations can contain field names that don’t exist in the underlying datasource, they can nest other web parts and user controls, or they can have raw C# code.

One technique that I use to troubleshoot a Transformation is to start commenting out large chunks of the HTML or Server Side code to try and narrow down which area of the Transformation is causing the problem. This is also probably one of the most complex items to troubleshoot out of all of the items in this list.

 

Kentico CMS Edit Transformation

 

 

4. Enable Debugging in the CMSSiteManager

Debugging allows you to see all the things that are happening on a page in Kentico even down to the web part level. SQL Requests are your biggest source of information here. If you are in a pinch you can even watch the debugging information on a live site by enabling the debugging info by going to CMSSiteManager –> Settings –> Expand System –> Debug settings page. Once you have unchecked Disable Debugging Kentico starts tracking just about everything on every page request. After that you can go to CMSSiteManager –> Administration –> System –> Debug and click on the SQL Queries tab on a site. Just make sure that Enable Debug on Live Site is unchecked first and also don't forget to turn it off once you have what you need.

This is very beneficial because the right hand column of the SQL Queries tab shows you what web part or control the SQL call originated from. You can use this so see if the SQL is valid and successful or is erroring right then and there. There is also more important and useful information here because the debugger will tell you the number of rows and number of columns returned on each SQL call as well. All good information to have when trying to figure out a problem with a web part.

 

Kentico CMS SQL Debug

 

 

5. Check the Event Log

Yes it seems like a simple one, but almost all exceptions are going to be logged to the Kentico Event Log. This should be one of the first places you look to see what information you have on any errors. Remember that the best way to view the Event Log is from inside of CMSSiteManager. I say this because it shows you global events of your entire Kentico instance and not just site specific ones. The Event Code column can be a good place to start filtering the Event Log on. You can filter to just errors of code LOADWEBPART or others. Again useful in troubleshooting Kentico problems.

You can click the View action on the left most column to see a full detailed description of the specific event as well.

 

Kentico CMS Event Log

 

 

6. Compare the Web Part Properties XML of a Page Template

Each page template in Kentico CMS is stored as a row of data in SQL Server as you would expect. There is actually a single column used to store what is configured on each of the page templates in the site. This column has an XML representation of all of the web part properties on that template and all of the web part’s setting values. Basically it is a big dictionary of each web part on the template.

This data is actually exposed in the CMSSiteManager UI for a page template. To see it click on any page template and choose the page template and then click the Web Parts tab. Often when troubleshooting a page that isn’t working I will grab this XML and compare it a dev instance via WinMerge or some other visual diff too.

Also as the warning suggests, you should only edit this data if you know exactly what you are doing. It has to be 100% right. However, if you have a good working copy on your QA or Dev instance you take some of the XML from that instance and overwrite your destination template if you have to. Just be extra careful with this one, with great power comes great responsibility. 

 

Kentico CMS Page Template Web Part Properties

 

Kentico CMS WinMerge

 

 

Conclusion

Well there you have it. I have shown you 6 things to check when your web part is not working in Kentico CMS. These tips apply to all versions of Kentico. Hopefully one or more of them will save you some heartache next time you have to troubleshoot a problem in Kentico. If you have your own tips feel free to leave them in the comments section on this post.

You might also be interested in

[X]

Be the first to know about my latest Kentico Tips & Tricks!

Do not show again