Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • shobhit agarwal 8 posts 108 karma points
    Dec 01, 2015 @ 09:54
    shobhit agarwal
    0

    how to write server side script in umbraco content field

    i want to know can we write any server side script to umbraco content field and if yes then how to achieve the same in umbraco.
    for instance:
    my document type (static page) has one property - bodycontent(textbox multiple)
    my template (static page) has the code to render @Umbraco.Field("Bodycontent")
    content page - i have created 404, 403...etc page using this template. now what i want is to write some server side script to content section. i do not want to write server side script to template because that will be applied to each content section.
    Is there a way to write some server side script to content section. will appreciate any help.

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Dec 10, 2015 @ 23:42
    Marc Goodson
    100

    Hi Shobhit

    You could create a different template to put your server side code in that needs to be applied to only one page, and not to every content page.

    Then for your content doc type you can allow this alternative template to be used; in addition to your normal content template.

    Then for the page that needs to have the special server side code, on the properties tab, select your new alternative template and republish.

    (If the page is a different kind of page to the rest of your site, consider creating it as a new document type + template; and give it a different icon; then in the back office tree, it will be clear this is a different type of content page)

    Another completely different approach would be to wrap your serverside code in a Macro - and insert the macro only onto the specific page via a rich text area field.

    https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/

Please Sign in or register to post replies

Write your reply to:

Draft