Sitefinty Page: how to access Code Behind Type (CodeBehindType))

6 posts, 0 answers
  1. omhoge
    omhoge avatar
    8 posts
    Member since:
    Jan 2007

    Posted 16 Mar Link to this post

    How do you set the CodeBehindType property for a Sitefinity Page in C# code?

     

    We are importing a lot of legacy content into Sitefinity, currently we trigger the import via a Sitefinity Page with our custom code in its Code Behind Type option in the Sitefinity editor.

    The imported pages are inheriting that CodeBehindType, and we need reset that property during the import.

     

    Thanks for considering my question.

  2. Pavel Benov
    Admin
    Pavel Benov avatar
    3 posts

    Posted 18 Mar Link to this post

    Hello John,

    As you might know Sitefinity's pages consist of 2 objects - e.g. PageNode (for navigation) and PageData (for presentation). The CodeBehindType property is available from the PageData object of a page:

    var pd = new PageData();
    pd.CodeBehindType = "Some.Type.Here";

    You can check our Documentation for detailed CRUD API samples with Pages (both PageNode and PageData objects included) in order to alter your code to fit your requirement.

    http://docs.sitefinity.com/for-developers-query-pages

    Regards,
    Pavel Benov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. omhoge
    omhoge avatar
    8 posts
    Member since:
    Jan 2007

    Posted 18 Mar in reply to Pavel Benov Link to this post

    Thank you very much Pavel.

    Unfortunately that did not work with the imported content type:

    DynamicContent legacyPageContentItem = this.DynamicModuleManager.CreateDataItem(this.LegacyPageContentType);
                legacyPageContentItem.CodeBehindType

    errors out.

    These are not built-in SF pages, but custom content types for pages from the legacy system,  and they still call the importing page's code behind when they are previewed, so they re-start the import and delete themselves.  They will not display in a page with the widget for listing and display content that the module builder created.  that's why I'm trying to clear out that code behind property.

     

  4. Pavel Benov
    Admin
    Pavel Benov avatar
    3 posts

    Posted 23 Mar Link to this post

    Hi John,

    From what I am understanding you have a Sitefinity page, where you have used its CodeBehindType property to set a code behind file. In the code behind file (probably Page_Load event) you are using API to get your legacy content and store it in Sitefinity. Is this assumption correct so far?

    In your last reply I can see that you are using DynamicContent type, which is the type used by modules created through Module builder, so I assume you are storing the legacy content into a Dynamic module (from Module builder).

    It is important to note here that DynamicContent type does not have CodeBehindType property for it is a model type of object. 

    Can you tell me on which page have you placed the automatically generated widget for your Dynamic module? If it is placed on the page which you use to import content, please move it to a different page and see if the code is executed again when you preview.

    If it still does, then go to Content->Your module->Pages where items like this are published. If the page which you use to import content is at the top of the list with priority 1, move it to the bottom (using the Actions menu).

    More information on this can be found here:

    http://docs.sitefinity.com/locations-of-content-items-canonical-urls

    Regards,
    Pavel Benov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. omhoge
    omhoge avatar
    8 posts
    Member since:
    Jan 2007

    Posted 24 Mar Link to this post

    Thank you, Pavel, for that information, most helpful.
  6. Pavel Benov
    Admin
    Pavel Benov avatar
    3 posts

    Posted 25 Mar Link to this post

    Hi John,

    I am glad I could help.

    Regards,
    Pavel Benov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
Back to Top