0

@Edited after Mark's answer.

I have a ascx control where I have defined some variables.

<%
var showFilters = RenderingParameters.ShowFilters;
var minimizeCardHeight = RenderingParameters.MinimizeCardHeight;
var numberOfProfiles = 0;
%>
<sc:EditFrame ID="editContributors" runat="server" Title="Contributors Area" Buttons="/sitecore/content/Applications/WebEdit/Edit Frame Buttons/Test Button">
<div class='test'>
<% if(minimizeCardHeight) { %> 
<div class="divider"></div>
<% } %>
</div>
</sc:EditFrame>

Now, in visual studio there is no error shown for any variables but when I publish the code and run the page in Experience Editor, a compilation error is thrown

CS0103: The name 'minimizeCardHeight' does not exist in the current context

Please let me know what I am doing wrong here.

0
1

A number of things.

  1. You cannot have the <%= inside the <sc:EditFrame> control. It will not be evaluated. <%= sends its output to the output stream, it does not act as a variable as you seem to assume. See https://stackoverflow.com/questions/370201/why-will-expressions-as-property-values-on-a-server-controls-lead-to-a-co
  2. You cannot edit Rendering Parameters using an Edit Frame. See Inline editing of rendering parameters in Experience Editor for details.
1
  • thanks, I understood that <%= %> is like response.write and will not work for variables like I'm thinking it would. I am not able to fetch the variables even when I am not using <%= %>. I will update my code to show what I'm trying to say.
    – Shaurya
    Oct 18 '18 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.