Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7913311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:48:45+00:00 2026-06-03T13:48:45+00:00

I am creating a C# TBB(C# Code fragment). For that I need to write

  • 0

I am creating a C# TBB(C# Code fragment). For that I need to write a userdefined method. I tried creating it using <%! %>. How to access the user defined method in the code. Thanks in advance. Please suggest me a way to solve this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:48:46+00:00Added an answer on June 3, 2026 at 1:48 pm

    The TOM.NET API reference provides the following example:

    <%@ Import Namespace="Tridion.ContentManager.Publishing"%>
    <%!
    private string ExtraString()
    {
        return "Something added by the C# template";
    }
    %>
    log.Debug("Executing C# template");
    if (engine.RenderMode == RenderMode.Publish)
    {
        package.GetByName(Package.OutputName).AppendToStringValue(ExtraString());
    }
    

    In addition to the above, the following syntax is supported:

    <%@Import Namespace="..." %> 
    

    Imports the namespace enclosed between the quotation marks into the code fragment. Any class you import must be present in the Global Assembly Cache.

    <%! ... %> 
    

    Declares methods, constants and classes for the rest of the code fragment to use. The declarations cannot contain the string ‘%>’. Note that any classes you create can only be referenced within the code fragment.

    <%RunTemplate Template="tcm:1-184-2048" Class="Tridion.Templating.Examples.ExampleTemplateClass"%> 
    

    Runs a specific .NET Assembly Template Building Block, identified by the URI in the Template attribute. This statement is typically generated by SDL Tridion 2009 itself when you upload a .NET assembly, to provide access to a specific class in the .NET Assembly.

    <%@Assembly Name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"%> 
    

    Inserts a reference to a nonstandard .NET assembly, which must be present in the Global Assembly Cache. Use the full assembly name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a Drawable that is completely empty seems like a common need, as a
I am using SDL Tridion 2011 SP1. I am creating the Dreamweaver TBB for
I am trying to parallelize some Image Matching code written in OpenCV using TBB.
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL
Creating a simple UI using MS Access, hoping to do minimal actual coding (actually
Creating a document fragment using plain Javascript is dead simple: var docFragment = document.createDocumentFragment();
I am creating a C# TBB. I have the XML code as shown below.
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
I am working on creating .NET TBB for Tridion 2011 SP1. I have two
Creating liquid layouts is an immense pain. Now, I totally understand that tables should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.