/// <summary> Gets the parameters required for selecting the <paramref name="menuTab"/>. </summary> /// <param name="menuTab"> /// The <see cref="MenuTab"/> that should be selected by the when using the returned URL parameters. /// Must not be <see langword="null"/>. /// </param> /// <returns> /// A <see cref="NameValueCollection"/> that contains the URL parameters parameters required by this /// <see cref="TabbedMenu"/>. /// </returns> public virtual NameValueCollection GetUrlParameters(IMenuTab menuTab) { ArgumentUtility.CheckNotNull("menuTab", menuTab); MainMenuTab mainMenuTab = menuTab as MainMenuTab; SubMenuTab subMenuTab = menuTab as SubMenuTab; string[] tabIDs; if (mainMenuTab != null) { tabIDs = ConvertTabIDsToArray(mainMenuTab, null); } else if (subMenuTab != null) { tabIDs = ConvertTabIDsToArray(subMenuTab.Parent, subMenuTab); } else { throw new NotSupportedException(string.Format("menuTab is of unsupported type '{0}'.", menuTab.GetType().FullName)); } string value = (string)TypeConversionProvider.Convert(typeof(string[]), typeof(string), tabIDs); NameValueCollection urlParameters = new NameValueCollection(); urlParameters.Add(SelectionID, value); return(urlParameters); }
/// <summary> Gets the IDs of the tabs to be selected from the query string. </summary> /// <returns> /// A string array containing the ID of the <see cref="MainMenuTab"/> at index 0 and the ID of the /// <see cref="SubMenuTab"/> at index 1. If no selected tab could be found, the array is empty. /// </returns> private string[] GetSelectionFromQueryString() { string[] selection = null; if (!IsDesignMode) { string value; if (Page is IWxePage) { value = WxeContext.Current.QueryString[SelectionID]; } else { value = Context.Request.QueryString[SelectionID]; } if (value != null) { selection = (string[])TypeConversionProvider.Convert(typeof(string), typeof(string[]), value); } } if (selection == null) { selection = new string[0]; } return(selection); }