Is it easy to integrate .NET into your RedDot CMS project? Yes it is, if you know how and obey some simple rules. This article gives you a best practice on how to include any .NET functionality for your published website within your RedDot CMS templates.
Inline code within a content class can’t be versioned as it could be with a version control system when developing standard .NET solutions outside of any CMS. You can’t develop or test properly using inline code within the CMS. Whenever you have to change the .NET part of your project you would need a RedDot Consultant or some of their knowledge and hence your project doubles up on resources. Don’t integrate inline code within your CMS.
There is a clear understanding of what your CMS should handle for you – your content – and what it should not take care of – styling and dynamic functionality may it be Javascript, .NET or any other scripting technology. The CMS is your data storage and management layer, the web server is your presentation and visualization layer and hence it is the point where dynamic functionality, styling and user interaction takes place. By keeping those parts separate you ensure to have a stable, scalable and furthermore easily maintain- and upgradeable Content Management Solution. Read more on this topic here
Instead of just adding a page directive followed by your inline code you should use user controls. Given that your code will be used on your website and not within the Open Text CMS ASP.NET User Controls are the best way to embedded dynamic functionality within your project.
There are basically two points where .NET is included in your template. The first one needs to be in every template which uses User Controls unless you integrate it using a container. The second one works as placeholder for the .NET functionality:
Referencing .ascx files and placing User Controls within templates
Read more »
We avoid putting “@ Register” tags into every template by registering tag prefixes globally in the web.config file. That way you can create a MySuchAndSuchUserControl content class and the content authors can plonk them wherever they like.
You can also create a “CS” variant for code-behind files which use FileRead render tags to pull their content in from a regular .net project. Combine with VSS and a build machine to ensure your CMS always has up to date code and you can use CMS elements in your C#!
User Controls are exactly the way we figured out to integrate ASP.NET into our RedDot projects as well!
Two more hints:
1. The page directive is unnecessary if you make C# the default instead of VB in the IIS ASP.NET configuration. Like this you avoid the limitation of only one page directive per ASPX file.
2. If your UC requires content/translation from within RedDot you could define public properties in your UC with getters and setters. You may then pass the content place holder to the UC like this:
<uc:Search ID=”Search” runat=”server” SubmitButtonCaption=”<%stf_submit_button_caption%>” />