Example #1
0
        public void AddLinkButtonTwo(ControlCollection cc, string storefrontUrl)
        {
            // Add code to page for the next navbar piece
            Page   page   = (Page)HttpContext.Current.Handler;
            string format = "<td class='navBarSeparator'></td><td class='navBarCell'><div class='navBarButton' style='float: left;'><div class='navBarButton-t'><div class='navBarButton-b'><div class='navBarButton-l'><div class='navBarButton-r'><div class='navBarButton-tl'><div class='navBarButton-tr'><div class='navBarButton-bl'><div class='navBarButton-br'><div class='navBarButton-inner'><a class='navBarButton' target='_blank' href='{0}'>{1}</a></div></div></div></div></div></div></div></div></div></div></td>";

            if (page.Request.Url.ToString().IndexOf("previesreport.aspx") != -1)
            {
                format = format.Replace("navBarButton", "navBarButtonSelected");
            }

            // Add the name for our navbar piece the user specified
            string text = string.Format(format, storefrontUrl, StorefrontAPI.Storefront.GetValue("ModuleField", _SA_LINK_NAME_TWO, _UNIQUE_NAME));

            // Get user specfied link for link two button
            string linkTwoUrl = Storefront.GetValue("ModuleField", _SA_LINK_TWO_URL, _UNIQUE_NAME);           // This variable holds the link two url the user provided from the extension setup page

            // Log that the text has been set and what it is

            /*
             * LMTF.LogMessagesToFile(storeFrontName, LOG_FILENAME1, LOG_FILENAME2, $"|----------------------------------------------------------|");
             * LMTF.LogMessagesToFile(storeFrontName, LOG_FILENAME1, LOG_FILENAME2, "AddLinkButton called text: " + text);
             * if ((string)ModuleData[_SA_DEBUGGING_MODE] == "true")
             * {
             *  LogMessage($"|----------------------------------------------------------|");
             *  LogMessage("AddLinkButton called text: " + text);
             * }
             */

            //  Add navbar to correct place in list
            foreach (Control startingControl in cc)
            {
                if (startingControl.ToString().IndexOf("pageheader_ascx") != -1)
                {
                    Control childControl = ControlFinder.FindChildControl(startingControl, "phLeftSide");
                    try
                    {
                        childControl.Controls.AddAt(childControl.Controls.Count - 2, new LiteralControl(text));
                    }
                    catch (Exception ex)
                    {
                        string message = ex.Message;
                    }
                }
                if (startingControl.HasControls())
                {
                    AddLinkButtonTwo(startingControl.Controls, linkTwoUrl);
                }
            }
        }