How can i use Macroses with custom web-part field? (code-behind)

Sergey Lebedev asked on March 3, 2014 06:05

Hello, Here is the thing.

I cloned Kentico BizForm as in http://devnet.kentico.com/docs/7_0/devguide/index.html?resolving_macros_using_api.htm Next, i added a custom field in my new web-part throuht Kentiko CMS. Next, configured menu item throught design section.

I have a problem here - I need to resolve this macros in code-behind. I think i need -

CMSContext.CurrentResolver.ResolveMacros(str); or this.ResolveMacros(str); I try to use GetValue to obtain value from my field - but it just "eats" macro.

So, how can i do something like this: var str = this.GetValue("MyValue"); //for example MyValue = "{%Test%}"; // i want str to be "{%Test%}" // but str == "" this.ResolveMacros(str);

Correct Answer

Sergey Lebedev answered on March 3, 2014 06:34

Okay, thanks, there is a dirty hack.

this.DisableMacros = true;      //disable macros
var str = this.GetValue("MyValue");
//str == "{%Test%}", yaay
this.DisableMacros = false;     //enable macros.    
1 votesVote for this answer Unmark Correct answer

Recent Answers


Sergey Lebedev answered on March 3, 2014 06:09

Quick pastebin link, sorry http://pastebin.com/D77ihNuK

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 3, 2014 06:31

Adding the property within the Kentico UI for the webpart is only half of the chore. You also need to modify the code behind and add a public property named the same. Take a look at the webpart dev docs.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.