1

Is there a way to get Rendering Parameter in cshtml view file without the glass mapper model?

The existing View is already using a model. So want to get the parameter without a model or glass mapper.

The Rendering parameter is a multilist field, I need the selected value of the field.

3

2 Answers 2

0

You can use RenderingContext.Current.Rendering.Parameters

@{
  var rendering = RenderingContext.Current.Rendering;
  string someParameter = rendering.Parameters["my multilist field"];
}
0

You can get the rendering parameters like this in your view.

 string TitleCss = string.Empty, DescriptionCss = string.Empty;

 var rc = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull;
 if (rc != null)
 {
     var parms = rc.Rendering.Parameters;
     TitleCss = parms["TitleCss"];
     DescriptionCss = parms["DescriptionCss"];
              
     Sitecore.Data.Fields.MultilistField multiselectField = param["your multilist filed"];

     Sitecore.Data.Items.Item[] items = multiselectField.GetItems();

 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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