Get sublayout parameters from usercontrol


/ Published in: C#
Save to your folder(s)

Gets parameters set on the sublayout in presentation details as a property, just use parameters["paramname"] to get a value.
Needs ref to Sitecore.Kernel.dll and "using Sitecore.Web;".


Copy this code and paste it in your HTML
  1. private NameValueCollection _parameters = null;
  2. private NameValueCollection parameters
  3. {
  4. get
  5. {
  6. if (_parameters == null)
  7. {
  8.  
  9. if (String.IsNullOrEmpty(this.Attributes["sc_parameters"]))
  10. return new NameValueCollection();
  11. else
  12. _parameters = WebUtil.ParseUrlParameters(this.Attributes["sc_parameters"]);
  13. }
  14.  
  15. return _parameters;
  16. }
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.