Writing Macro in ASCX layout

Naresh Ede asked on October 9, 2017 07:52

Hi

I want to write macro inside ASCX layout, for this text/xml macro

{%CurrentUser.IsInRole("guest")?"html content":"html content" #%}

The Above text/xml macro not resolving in ASCX layout.

please help to write the same macro in ASCX layout

Recent Answers


Michal Samuhel answered on October 9, 2017 08:12

Hi Naresh,

The code of the transformation supports ASCX markup, which means the same syntax that you would use to edit standard web forms or user controls. So you can use our API methods directly along with proper syntax it should look like:

<% CurrentUser.IsInRole("RoleName", CurrentSite.SiteName); %>

You can find more detail explanation as well as an example on this link.

1 votesVote for this answer Mark as a Correct answer

Amit Srivastava answered on October 9, 2017 09:32

Hi Naresh,

Use below code to check you condition in ascx transformation..

<%# CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("guest", CMS.SiteProvider.SiteContext.CurrentSiteName) ? "Hello":"Hi" %>

Thanks,

2 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on October 9, 2017 15:40

Using the code blocks as suggested by Amit can lead to this issue. I would go for the Michal's suggestion or create custom transformation method.

0 votesVote for this answer Mark as a Correct answer

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