Access parameters passed to a Management Panel from a widget (IScriptablePlugin)

I have a custom Management Panel that is using a widget to render its content.  I am passing parameters via NameValueCollection when getting the URL - when  load the panel I can see my parameters in the URL, but I'm not entirely sure how to access these parameters in my widget.

I tried $core_v2_page.GetQueryStringValue and that did not work.

  • I'm always tempted to post this whenever I see someone need a solution but never post the solution :D

  • Love that Christopher! Completely identify with it too! 

    Even worse than those who reply but have completely misunderstood your issue and respond with a solution for something totally unrelated and then have the audacity to suggest it as the answer! 

    Happened to me recently on a DJI forum, had to hold myself back from typing out 'That was absolutely no help whatsoever.... '  Joy 

  • It's fine don't worry about it Slight smile This isn't something I'm looking for personally, I only encourage people to share solutions if it's going to be beneficial to others that have the same problem. 

    It's too easy often to find a problem online and then someone simply says "fixed it!" and the reaction by the person searching is often "what? how?" Slight smile

  • It's all about knowledge sharing Luke. 'I have/had this problem, this is how I fixed it' kind of thing. Helping others who may have the same issue. People consult forums looking for a solution. If all they find it others posting the issue without a resulting solution then it's no help at all. 

    A few years back my partner needed help to fix the transmission on his Manitou Telehandler so he consulted a dedicated forum. With some advice from forum members he managed to fix it and posted updates with photos as he went along to help others who also needed help with it too. After 5 years or so he looked back at the thread and it had hundreds of thousands of views! We've lost the link now so can't see how many views it's had to date. I said he should have vlogged it on YouTube as we'd have made a fortune by now if we'd monetized it... Joy

    But yeah if you want to add the code here that's great, helps others. But if you don't then it's up to you Slight smile

  • To fix this, you need to create a private scriptable extension and add it to your panel.


    using System;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Telligent.Evolution.Extensibility.UI.Version1;
    
    namespace HearingFirst.Learning.Panels.Management
    {
        public class PrivateExtension : IContextualScriptedContentFragmentExtension
        {
            #region IContextualScriptedContentFragmentExtension
    
            public string ExtensionName { get { return "private"; } }
    
            public object GetExtension(NameValueCollection context)
            {
                return new PrivateExtensionApi(context);
            }
    
            #endregion
        }
    
        public class PrivateExtensionApi
        {
            private NameValueCollection _context;
    
            public PrivateExtensionApi(NameValueCollection context)
            {
                _context = context;
            }
            public int ChapterId
            {
                get { return _context == null ? 0 : Convert.ToInt32(_context["ChapterId"]); }
            }
            public int CourseId
            {
                get { return _context == null ? 0 : Convert.ToInt32(_context["CourseId"]); }
            }
            public int ProviderId
            {
                get { return _context == null ? 0 : Convert.ToInt32(_context["ProviderId"]); }
            }
            public int RequirementId
            {
                get { return _context == null ? 0 : Convert.ToInt32(_context["RequirementId"]); }
            }
            public string RequirementTypeId
            {
                get { return _context == null ? null : _context["RequirementTypeId"]; }
            }
            public int ReactionId
            {
                get { return _context == null ? 0 : Convert.ToInt32(_context["ReactionId"]); }
            }
            public string ReactionTypeId
            {
                get { return _context == null ? null : _context["ReactionTypeId"]; }
            }
            public string TriggerTypeId
            {
                get { return _context == null ? null : _context["TriggerTypeId"]; }
            }
        }
    }
    


    And then within the Register method of your IAdministrationExplicitPanel
    public void Register(IScriptedContentFragmentController controller)
            {
                _scriptController = controller;
    
                var fragmentOptions = new ScriptedContentFragmentOptions(_fragmentId)
                {
                    CanBeThemeVersioned = false,
                    CanHaveHeader = true,
                    CanHaveWrapperCss = true,
                    CanReadPluginConfiguration = true,
                    CanWritePluginConfiguration = false,
                    IsEditable = true
                };
    
                fragmentOptions.Extensions.Add(new PrivateExtension());
    
                _scriptController.Register(fragmentOptions);
            }


    Then within your administration panel widget, you can access query string parameters like this:  $private.PropertyName