/// <summary>
        ///   Implements <see cref="IWxePage.GetPermanentUrlParameters">IWxePage.GetPermanentUrlParameters()</see>.
        /// </summary>
        public NameValueCollection GetPermanentUrlParameters()
        {
            NameValueCollection urlParameters = CurrentPageFunction.VariablesContainer.SerializeParametersForQueryString();

            ISmartNavigablePage smartNavigablePage = _page as ISmartNavigablePage;

            if (smartNavigablePage != null)
            {
                NameValueCollectionUtility.Append(urlParameters, smartNavigablePage.GetNavigationUrlParameters());
            }

            return(urlParameters);
        }
Example #2
0
        /// <summary> Creates a <see cref="CommandInfo"/> for the <see cref="HrefCommand"/>. </summary>
        /// <param name="parameters">
        ///   The strings inserted into the href attribute using <c>string.Format</c>.
        /// </param>
        /// <param name="onClick">
        ///   The string always rendered in the <c>onClick</c> tag of the anchor element.
        /// </param>
        /// <param name="additionalUrlParameters">
        ///   The <see cref="NameValueCollection"/> containing additional url parameters.
        ///   Must not be <see langword="null"/>.
        /// </param>
        /// <param name="includeNavigationUrlParameters">
        ///   <see langword="true"/> to include URL parameters provided by <see cref="ISmartNavigablePage"/>.
        ///   Defaults to <see langword="true"/>.
        /// </param>
        /// <exception cref="InvalidOperationException">
        ///   If called while the <see cref="Type"/> is not set to <see cref="CommandType.Href"/>.
        /// </exception>
        protected virtual CommandInfo GetCommandInfoForHrefCommand(
            string[] parameters,
            string onClick,
            NameValueCollection additionalUrlParameters,
            bool includeNavigationUrlParameters)
        {
            ArgumentUtility.CheckNotNull("parameters", parameters);
            ArgumentUtility.CheckNotNull("additionalUrlParameters", additionalUrlParameters);
            if (Type != CommandType.Href)
            {
                throw new InvalidOperationException("Call to GetCommandInfoForHrefCommand not allowed unless Type is set to CommandType.Href.");
            }

            string href = HrefCommand.FormatHref(parameters);

            if (includeNavigationUrlParameters)
            {
                ISmartNavigablePage page = null;
                if (OwnerControl != null)
                {
                    page = OwnerControl.Page as ISmartNavigablePage;
                }

                if (page != null)
                {
                    additionalUrlParameters = additionalUrlParameters.Clone();
                    NameValueCollectionUtility.Append(additionalUrlParameters, page.GetNavigationUrlParameters());
                }
            }
            href = UrlUtility.AddParameters(href, additionalUrlParameters);
            if (OwnerControl != null)
            {
                href = OwnerControl.ResolveClientUrl(href);
            }

            return(CommandInfo.CreateForLink(
                       StringUtility.EmptyToNull(_toolTip),
                       StringUtility.EmptyToNull(_accessKey),
                       href,
                       StringUtility.EmptyToNull(HrefCommand.Target),
                       StringUtility.EmptyToNull(onClick)));
        }