ASPX templates
Version 6.x > ASPX templates > Exposing a literal (or code behind value) through from ASPX template for use in a CMSEditableRegion View modes: 
User avatar
Member
Member
A.L. - 2/25/2013 2:51:59 PM
   
Exposing a literal (or code behind value) through from ASPX template for use in a CMSEditableRegion
Hi,

We have a custom e-commerce system integrated with Kentico (v6) as an external web service. Upon check out the system display the receipt information in an ASPX template which pulls in both information from the external web service and from the Kentico CMS. The issue I'm having is finding the simplest way to pull the value of a literal into the cms:CMSEditableRegion of the template to build a custom link with the text. I'd like to reference the data that is used to fill in this literal instead of building a small module that makes an additional call on its own.

For example, let's call the template receipt.aspx. In this template there are both CMSEditableRegion tags (for Kentico content) and then literals which are filed out with order specific info from the 3rd party party web service. Fr instance:

<asp:Literal ID="UserID" runat="server" />
<cms:CMSEditableRegion ID="uxEditableRegionH1" runat="server" RegionTitle="Confirmation Messaging" RegionType="TextBox" />

The UserID literal is filled in with the 3rd party order ID by the receipt.aspx.cs (code behind) file. My issue is that I want to pull through this same UserID value into something that can be accessed like a marco in the CMSEditableRegion. The reason is I want content creators to be able to build custom links that use the UserID as a query parameter. Ideally something like http://link.com?userid={%literal.UserID%} - (made up syntax).

Now I know I can implement this a number of ways, but they all make an additional call. For instance I can do a web part/widget however that would necessitate a second call to the Web Service which is inefficient. Creating a custom Macro also has this same issue. I could of course also hard code the link using the literal in the .ASPX template but, like any good programmer, I don't like to hardcode ;-)

Is there some way to pull this literal value through to the CMSEditableRegion? The data is in the codebehind and even the literal markup but I don't see how to reference it ... or is the ASPX lifecycle such that I can't access the code behind or literal from the EditableRegion since it is post-operation?

Thanks in advance for reading this long question and offering suggestions. I apologize in advance if this topic has already been covered, I wasn't able to find any reference to it in the forums.

Thanks,
A.L.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/2/2013 11:40:56 AM
   
RE:Exposing a literal (or code behind value) through from ASPX template for use in a CMSEditableRegion
Hi,

I am updating this post according our e-mail conversation in case somebody else is interested.

I would rather use static HTML web part where you just need to set the text property. Or use some other control - text area, default ASP.Net.

In editable region you need to use LoadContent or SaveContent methods (both with the page info parameter) to load the value to the editable region. I think this may be even worse that one more call through macro or calling the service.

However, this blog post may give you more details and ideas.

Best regards,
Juraj Ondrus