ASPX templates
Version 5.x > ASPX templates > Error Creating Control - Fix View modes: 
User avatar
Member
Member
chris.percival-oakwood-dc - 6/17/2010 6:16:51 AM
   
Error Creating Control - Fix
I have recently converted my Kentico Web Site to a web application project (well worth doing BTW). One issue I started having after I converted is I would get an error on controls in the designer:

Error Creating Control - Session state can only be used when enableSessionState is set to ture.... etc.

If you're building a template aspx page and you're deriving from CMS.UIControls.TemplatePage (as you should be), then you will get this error as TemplatePage is derived from AbstractCMSPage which accesses the session on init. The work around is to add the following code in your page:

        protected override void OnInit(EventArgs e)
        {
            if (!DesignMode)
                base.OnInit(e);
        }


This would be worth adding to the AbstractCMSPage code for Kentico v6.. :)

User avatar
Member
Member
chris.percival-oakwood-dc - 6/17/2010 6:18:44 AM
   
RE:Error Creating Control - Fix
Here's the microsoft blog entry on the issue:

http://blogs.msdn.com/b/webdevtools/archive/2010/04/15/rendering-issue-in-visual-studio-2010-when-accessing-the-session-state-in-the-oninit-method.aspx

User avatar
Member
Member
chris.percival-oakwood-dc - 6/17/2010 6:19:25 AM
   
RE:Error Creating Control - Fix
Note this is a Visual Studio 2010 issue only..

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/17/2010 8:11:47 AM
   
RE:Error Creating Control - Fix
Hi,

Thank you for sharing with this experience. I forwarded it to our developers so they can consider it for the next version.

Best regards,
Juraj Ondrus