private StringBuilder MakeCss(DataTable dtObj, string SectionNm, CurrPrj CPrj, CurrSrc CSrc)
        {
            StringBuilder sb = new StringBuilder();
            string        str;
            DataView      dvLnk = null;

            sb.Append(Environment.NewLine + "/* " + SectionNm + " */" + Environment.NewLine);
            foreach (DataRowView drv in dtObj.DefaultView)
            {
                str = sb.ToString();
                if (!string.IsNullOrEmpty(drv["SctGrpRowId"].ToString()) && str.IndexOf(".SctGrpRow" + drv["SctGrpRowId"].ToString()) < 0)
                {
                    sb.Append(".SctGrpRow" + drv["SctGrpRowId"].ToString() + " { " + drv["SctGrpRowCss"].ToString() + " }" + Environment.NewLine);
                }
                if (!string.IsNullOrEmpty(drv["SctGrpColId"].ToString()))
                {
                    if (str.IndexOf(".SctGrpCol" + drv["SctGrpColId"].ToString()) < 0)
                    {
                        sb.Append(".SctGrpCol" + drv["SctGrpColId"].ToString() + " { " + drv["SctGrpColCss"].ToString() + " }" + Environment.NewLine);
                    }
                    if (str.IndexOf(".SctGrpDiv" + drv["SctGrpColId"].ToString()) < 0)
                    {
                        sb.Append(".SctGrpDiv" + drv["SctGrpColId"].ToString() + " { " + drv["SctGrpColDiv"].ToString() + " }" + Environment.NewLine);
                    }
                }
                sb.Append(".PageObj" + drv["PageObjId"].ToString() + " { " + drv["PageObjCss"].ToString() + " }" + Environment.NewLine);
                using (GenSectionAccessBase dac = GetGenSectionAccess())
                {
                    dvLnk = dac.GetPageLnk(drv["PageObjId"].ToString()).DefaultView;
                }
                foreach (DataRowView drvn in dvLnk)
                {
                    sb.Append(".PageLnk" + drvn["PageLnkId"].ToString() + " { " + drvn["PageLnkCss"].ToString() + " }" + Environment.NewLine);
                }
            }
            return(sb);
        }
        private StringBuilder MakeHAscx(DataTable dtObj, string SectionNm, CurrPrj CPrj, CurrSrc CSrc)
        {
            DataView      dvLnk = null;
            DataRow       drObj = null;
            StringBuilder sb    = new StringBuilder();
            StringBuilder tm    = new StringBuilder();
            StringBuilder rp    = new StringBuilder();

            sb.Append("<%@ Control Language=\"c#\" Inherits=\"RO.Web." + SectionNm + "Module\" CodeFile=\"" + SectionNm + "Module.ascx.cs\" CodeFileBaseClass=\"RO.Web.ModuleBase\" %>" + Environment.NewLine);
            if (dtObj.Select("LinkTypeCd = 'CUL'").Count() > 0)
            {
                sb.Append("<%@ Register TagPrefix=\"rcasp\" Namespace=\"RoboCoder.WebControls\" Assembly=\"WebControls, Culture=neutral\" %>" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'MNT'").Count() > 0)
            {
                sb.Append("<%@ Register TagPrefix=\"Module\" TagName=\"MenuTop\" Src=\"MenuTopModule.ascx\" %>" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'MNS'").Count() > 0)
            {
                sb.Append("<%@ Register TagPrefix=\"Module\" TagName=\"MenuSid\" Src=\"MenuSidModule.ascx\" %>" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'PRF'").Count() > 0)
            {
                sb.Append("<%@ Register TagPrefix=\"Module\" TagName=\"Profile\" Src=\"MyProfileModule.ascx\" %>" + Environment.NewLine);
            }

            // Prepare body tm:
            if (SectionNm == "Header")
            {
                tm.Append("<div class=\"mobileHeader\">" + Environment.NewLine);
                if (dtObj.Select("LinkTypeCd = 'LGO'").Count() > 0)
                {
                    drObj = (dtObj.Select("LinkTypeCd = 'LGO'"))[0];
                    using (GenSectionAccessBase dac = GetGenSectionAccess())
                    {
                        dvLnk = dac.GetPageLnk(drObj["PageObjId"].ToString()).DefaultView;
                    }
                    tm.Append("    <div class=\"mobileLogo\"><asp:HyperLink NavigateUrl=\"" + Utils.AddTilde(dvLnk[0]["PageLnkRef"].ToString()) + "\" runat=\"server\"><asp:Image ImageUrl=\"" + Utils.AddTilde(dvLnk[0]["PageLnkAlt"].ToString()) + "\" runat=\"server\" /></asp:HyperLink></div>" + Environment.NewLine);
                }
                if (dtObj.Select("LinkTypeCd = 'BRC'").Count() > 0)
                {
                    tm.Append("    <div class=\"crumbSec\"><asp:HyperLink ID=\"cMobileCrumb\" CssClass=\"crumbMobile\" runat=\"server\" /></div>" + Environment.NewLine);
                }
                if (dtObj.Select("LinkTypeCd = 'MNT'").Count() > 0)
                {
                    tm.Append("    <div><section id=\"mobileMenu\"><div class=\"sb-navbar sb-slide\"><div class=\"sb-toggle-right\">" + Environment.NewLine);
                    tm.Append("        <asp:Label ID=\"mMenuTitle\" CssClass=\"mMenuTitle\" Text=\"MENU\" runat=\"server\"></asp:Label>" + Environment.NewLine);
                    tm.Append("        <div class=\"navicon-line\"></div><div class=\"navicon-line\"></div><div class=\"navicon-line\"></div>" + Environment.NewLine);
                    tm.Append("    </div></div></section></div>" + Environment.NewLine);
                }
                if (dtObj.Select("LinkTypeCd = 'PRF'").Count() > 0)
                {
                    tm.Append("    <div><asp:HyperLink ID=\"cSignIn\" CssClass=\"SignInMobile\" Text=\"Sign In\" runat=\"server\" /></div>" + Environment.NewLine);
                    tm.Append("    <div><asp:Button ID=\"cProfileButton\" CssClass=\"ProfBtnSec\" OnClientClick=\"slide(this); return false\" Text=\"Profile\" runat=\"server\" /></div>" + Environment.NewLine);
                }
                if (dtObj.Select("LinkTypeCd = 'HDR'").Count() > 0)
                {
                    tm.Append("    <div><asp:Button ID=\"cLinkButton\" CssClass=\"LinkBtnSec\" OnClientClick=\"openLinkSec(); return false;\" Text=\"Link\" runat=\"server\" /></div>" + Environment.NewLine);
                }
                if (dtObj.Select("LinkTypeCd = 'SSO'").Count() > 0)
                {
                    tm.Append("    <div><asp:Button ID=\"cSociButton\" CssClass=\"SociBtnSec\" OnClientClick=\"openSociSec(); return false;\" Text=\"Social\" runat=\"server\" /></div>" + Environment.NewLine);
                }
                tm.Append("</div>" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'BKI'").Count() > 0)
            {
                drObj = (dtObj.Select("LinkTypeCd = 'BKI'"))[0];
                tm.Append("<div class=\"HideBgImgOnMobile PageObj" + drObj["PageObjId"].ToString() + "\">" + Environment.NewLine);
            }
            string PreviousRow = string.Empty;
            string PreviousCol = string.Empty;

            foreach (DataRowView drv in dtObj.DefaultView)
            {
                if (PreviousRow != string.Empty && drv["RowCssClass"].ToString() != PreviousRow)
                {
                    PreviousRow = "NewRow"; PreviousCol = "NewCol";     // For PreviousCol below.
                }
                if (PreviousCol != string.Empty && drv["ColCssClass"].ToString() != PreviousCol)
                {
                    tm.Append("    </div>" + Environment.NewLine);
                    if (PreviousCol.LastIndexOf("-12") == PreviousCol.Length - 3)
                    {
                        PreviousRow = "NewRow"; PreviousCol = "NewCol";
                    }
                }
                if (PreviousRow != string.Empty && drv["RowCssClass"].ToString() != PreviousRow)
                {
                    tm.Append("</div></div>" + Environment.NewLine);
                }
                if (!string.IsNullOrEmpty(drv["SctGrpRowId"].ToString()) && !string.IsNullOrEmpty(drv["SctGrpColId"].ToString()))
                {
                    if (drv["RowCssClass"].ToString() != PreviousRow)
                    {
                        tm.Append("<div class=\"r-table " + drv["RowCssClass"].ToString() + " SctGrpRow" + drv["SctGrpRowId"].ToString() + "\"><div class=\"r-tr\">" + Environment.NewLine);
                        PreviousRow = drv["RowCssClass"].ToString(); PreviousCol = "NewCol";
                    }
                    if (drv["ColCssClass"].ToString() != PreviousCol)
                    {
                        tm.Append("    <div class=\"r-td " + drv["ColCssClass"].ToString() + " SctGrpCol" + drv["SctGrpColId"].ToString());
                        if (",LGO,CDD,CDT,BRC,".IndexOf("," + drv["LinkTypeCd"].ToString() + ",") >= 0)
                        {
                            tm.Append(" HideOnMobile");
                        }
                        tm.Append("\">" + Environment.NewLine);
                        PreviousCol = drv["ColCssClass"].ToString();
                    }
                    if (drv["LinkTypeCd"].ToString() == "LGO")
                    {
                        tm.Append("        <div ID=\"cLogoHolder\" class=\"SctGrpDiv" + drv["SctGrpColId"].ToString() + "\" runat=\"server\">" + Environment.NewLine);
                    }
                    else if (drv["LinkTypeCd"].ToString() == "HDR")
                    {
                        tm.Append("        <div ID=\"cLinkHolder\" class=\"link-content" + (SectionNm == "Header" ? " hideMoreButtonSec" : "") + " SctGrpDiv" + drv["SctGrpColId"].ToString() + "\" runat=\"server\">" + Environment.NewLine);
                    }
                    else if (drv["LinkTypeCd"].ToString() == "SSO")
                    {
                        tm.Append("        <div ID=\"cSociHolder\" class=\"link-content" + (SectionNm == "Header" ? " hideMoreButtonSec" : "") + " SctGrpDiv" + drv["SctGrpColId"].ToString() + "\" runat=\"server\">" + Environment.NewLine);
                    }
                    else if (drv["LinkTypeCd"].ToString() == "CUL")
                    {
                        tm.Append("        <div class=\"reset-lang SctGrpDiv" + drv["SctGrpColId"].ToString() + "\">" + Environment.NewLine);
                    }
                    else if (drv["LinkTypeCd"].ToString() == "CRS")
                    {
                        tm.Append("        <div class=\"flexslider SctGrpDiv" + drv["SctGrpColId"].ToString() + "\">" + Environment.NewLine);
                    }
                    else
                    {
                        tm.Append("        <div class=\"SctGrpDiv" + drv["SctGrpColId"].ToString() + "\">" + Environment.NewLine);
                    }
                    using (GenSectionAccessBase dac = GetGenSectionAccess())
                    {
                        dvLnk = dac.GetPageLnk(drv["PageObjId"].ToString()).DefaultView;
                    }
                    if (",HDR,SSO,LNK,CRS,".IndexOf("," + drv["LinkTypeCd"].ToString() + ",") >= 0)
                    {
                        if (drv["LinkTypeCd"].ToString() == "CRS")
                        {
                            tm.Append("        <ul class=\"slides PageObj" + drv["PageObjId"].ToString() + "\">" + Environment.NewLine);
                        }
                        else
                        {
                            tm.Append("        <div class=\"r-table PageObj" + drv["PageObjId"].ToString() + "\"><div class=\"r-tr\"><div class=\"r-td\">" + Environment.NewLine);
                        }
                        bool bFirstLnk = true;
                        foreach (DataRowView drvn in dvLnk)
                        {
                            tm.Append("            ");
                            if (drv["LinkTypeCd"].ToString() == "CRS")
                            {
                                if (bFirstLnk)
                                {
                                    tm.Append("<li class=\"flex-active-slide\">"); bFirstLnk = false;
                                }
                                else
                                {
                                    tm.Append("<li style=\"display:none;\">");
                                }
                            }
                            /* Stack image on top of text */
                            if (!string.IsNullOrEmpty(drvn["PageLnkImg"].ToString()))
                            {
                                // Cannot use asp:HyperLink because of mouseover script:
                                tm.Append("<asp:ImageButton ID=\"PageLnk" + drvn["PageLnkId"].ToString() + "Img\"");
                                tm.Append(" ImageUrl=\"" + Utils.AddTilde(drvn["PageLnkImg"].ToString()) + "\"");
                                // CSS applies to text if both image and text exist:
                                if (string.IsNullOrEmpty(drvn["PageLnkTxt"].ToString()))
                                {
                                    tm.Append(" CssClass=\"PageLnk" + drvn["PageLnkId"].ToString() + "\"");
                                }
                                if (!string.IsNullOrEmpty(drvn["PageLnkRef"].ToString()))
                                {
                                    if (drvn["PageLnkRef"].ToString().ToLower().IndexOf("javascript:") >= 0)
                                    {
                                        tm.Append(" OnClientClick=\"" + drvn["PageLnkRef"].ToString().Substring(drvn["PageLnkRef"].ToString().ToLower().IndexOf("javascript:") + 11) + "\"");
                                    }
                                    else if (drvn["Popup"].ToString() == "Y" && !drvn["PageLnkRef"].ToString().ToLower().StartsWith("mailto"))
                                    {
                                        tm.Append(" OnClientClick=\"SearchLink('" + drvn["PageLnkRef"].ToString() + "','','',''); return stopEvent(this,event);\" NavigateUrl=\"#\"");
                                    }
                                    else
                                    {
                                        tm.Append(" NavigateUrl=\"" + Utils.AddTilde(drvn["PageLnkRef"].ToString()) + "\"");
                                    }
                                }
                                tm.Append(" runat=\"server\" />");
                                // Prepare toggle script rp:
                                if (drv["LinkTypeCd"].ToString() != "LGO" && !string.IsNullOrEmpty(drvn["PageLnkAlt"].ToString()))
                                {
                                    rp.Append("    Sys.Application.add_load(function () { var pid = $('#<%=PageLnk" + drvn["PageLnkId"].ToString() + "Img.ClientID%>');" + Environment.NewLine);
                                    rp.Append("        pid.mouseover(function () { pid.attr('src','" + Utils.StripTilde(drvn["PageLnkAlt"].ToString(), false) + "'); });" + Environment.NewLine);
                                    rp.Append("        pid.mouseout(function () { pid.attr('src','" + Utils.StripTilde(drvn["PageLnkImg"].ToString(), false) + "'); });" + Environment.NewLine);
                                    rp.Append("    });" + Environment.NewLine);
                                }
                            }
                            if (!string.IsNullOrEmpty(drvn["PageLnkTxt"].ToString()))
                            {
                                tm.Append("<asp:HyperLink Text=\"" + drvn["PageLnkTxt"].ToString() + "\"");
                                tm.Append(" CssClass=\"PageLnk" + drvn["PageLnkId"].ToString() + "\"");
                                if (!string.IsNullOrEmpty(drvn["PageLnkRef"].ToString()))
                                {
                                    if (drvn["PageLnkRef"].ToString().ToLower().IndexOf("javascript:") >= 0)
                                    {
                                        tm.Append(" OnClick=\"" + drvn["PageLnkRef"].ToString().Substring(drvn["PageLnkRef"].ToString().ToLower().IndexOf("javascript:") + 11) + "\"");
                                    }
                                    else if (drvn["Popup"].ToString() == "Y" && !drvn["PageLnkRef"].ToString().ToLower().StartsWith("mailto"))
                                    {
                                        tm.Append(" OnClick=\"SearchLink('" + drvn["PageLnkRef"].ToString() + "','','',''); return stopEvent(this,event);\" NavigateUrl=\"#\"");
                                    }
                                    else
                                    {
                                        tm.Append(" NavigateUrl=\"" + Utils.AddTilde(drvn["PageLnkRef"].ToString()) + "\"");
                                    }
                                }
                                tm.Append(" runat=\"server\" />");
                            }
                            if (drv["LinkTypeCd"].ToString() == "CRS")
                            {
                                tm.Append("</li>" + Environment.NewLine);
                            }
                            else
                            {
                                tm.Append(Environment.NewLine);
                            }
                        }
                        if (drv["LinkTypeCd"].ToString() == "CRS")
                        {
                            tm.Append("        </ul>" + Environment.NewLine);
                        }
                        else
                        {
                            tm.Append("        </div></div></div>" + Environment.NewLine);
                        }
                    }
                    else /* Singular Object: do not allow button as PostBackUrl is causing validation issue. One can always style an image button or hyperlink as a button via css. */
                    {
                        tm.Append("        <div class=\"PageObj" + drv["PageObjId"].ToString() + "\">" + Environment.NewLine);
                        if (drv["LinkTypeCd"].ToString() == "LGO" || drv["LinkTypeCd"].ToString() == "IMG")
                        {
                            tm.Append("            <asp:HyperLink NavigateUrl=\"" + Utils.AddTilde(dvLnk[0]["PageLnkRef"].ToString()) + "\" runat=\"server\"><asp:Image ID=\"headerLogo\" CssClass=\"PageLnk" + dvLnk[0]["PageLnkId"].ToString() + "\" ImageUrl=\"" + Utils.AddTilde(dvLnk[0]["PageLnkImg"].ToString()) + "\" runat=\"server\" /></asp:HyperLink>" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "PRF")
                        {
                            tm.Append("            <Module:Profile ID=\"ModuleProfile\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "MNT")
                        {
                            tm.Append("            <Module:MenuTop ID=\"ModuleMenuTop\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "MNS")
                        {
                            tm.Append("            <Module:MenuSid ID=\"ModuleMenuSid\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "BRC")
                        {
                            tm.Append("            <asp:Literal ID=\"cBreadCrumb\" EnableViewState=\"false\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "CDD" || drv["LinkTypeCd"].ToString() == "CDT")
                        {
                            tm.Append("            <asp:Label ID=\"cWelcomeTime\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "CUL")
                        {
                            tm.Append("            <rcasp:ComboBox ID=\"cLang\" CssClass=\"inp-ddl\" Mode=\"A\" AutoPostBack=\"true\" OnPostBack=\"cbPostBack\" OnSearch=\"cbCultureId\" DataValueField=\"CultureTypeId\" DataTextField=\"CultureTypeLabel\" runat=\"server\" OnSelectedIndexChanged=\"cLang_SelectedIndexChanged\" />" + Environment.NewLine);
                            tm.Append("            <asp:ImageButton ID=\"lanResetBtn\" CssClass=\"lanResetBtn\" runat=\"server\" ImageUrl=\"~/images/reset.jpg\" OnClick=\"lanResetBtn_Click\" ToolTip=\"Reset Language\" CausesValidation=\"false\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "VER")
                        {
                            tm.Append("            <asp:Label id=\"cVersionTxt\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else if (drv["LinkTypeCd"].ToString() == "LAB")
                        {
                            tm.Append("            <asp:Label CssClass=\"PageLnk" + dvLnk[0]["PageLnkId"].ToString() + "\" Text=\"" + dvLnk[0]["PageLnkTxt"].ToString() + "\" runat=\"server\" />" + Environment.NewLine);
                        }
                        else /* Just in case */
                        {
                            tm.Append("" + Environment.NewLine);
                        }
                        tm.Append("        </div>" + Environment.NewLine);
                    }
                    tm.Append("        </div>" + Environment.NewLine);
                }
            }
            /* Take care of the last */
            if (PreviousCol != string.Empty)
            {
                tm.Append("    </div>" + Environment.NewLine);
            }
            if (PreviousRow != string.Empty)
            {
                tm.Append("</div></div>" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'BKI'").Count() > 0)
            {
                tm.Append("</div>" + Environment.NewLine);
            }

            // Complete the page:
            sb.Append("<script>" + Environment.NewLine);
            if (dtObj.Select("LinkTypeCd = 'HDR'").Count() > 0)
            {
                sb.Append("    function openLinkSec() { var linkContainer = $('#<%=cLinkHolder.ClientID%>'); if (linkContainer.hasClass('hideMoreButtonSec')) { linkContainer.removeClass('hideMoreButtonSec'); } else { linkContainer.addClass('hideMoreButtonSec'); }; }" + Environment.NewLine);
                sb.Append("    $(document).mouseup(function (e) { var linkContainer = $('#<%=cLinkHolder.ClientID%>'); if ($(window).width() <= 1024) { if (!linkContainer.is(e.target) && linkContainer.has(e.target).length === 0 && !linkContainer.hasClass('hideMoreButtonSec')) { openLinkSec(); } } });" + Environment.NewLine);
            }
            if (dtObj.Select("LinkTypeCd = 'SSO'").Count() > 0)
            {
                sb.Append("    function openSociSec() { var socialContainer = $('#<%=cSociHolder.ClientID%>'); if (socialContainer.hasClass('hideMoreButtonSec')) { socialContainer.removeClass('hideMoreButtonSec'); } else { socialContainer.addClass('hideMoreButtonSec'); }; }" + Environment.NewLine);
                sb.Append("    $(document).mouseup(function (e) { var socialContainer = $('#<%=cSociHolder.ClientID%>'); if ($(window).width() <= 1024) { if (!socialContainer.is(e.target) && socialContainer.has(e.target).length === 0 && !socialContainer.hasClass('hideMoreButtonSec')) { openSociSec(); } } });" + Environment.NewLine);
            }
            if (dtObj.Select("PageObjSrp is not null AND PageObjSrp <> ''").Count() > 0)
            {
                foreach (DataRowView drv in dtObj.DefaultView)
                {
                    if (!string.IsNullOrEmpty(drv["PageObjSrp"].ToString()) && sb.ToString().IndexOf(drv["PageObjSrp"].ToString()) < 0)
                    {
                        sb.Append(drv["PageObjSrp"].ToString() + Environment.NewLine);
                    }
                }
            }
            sb.Append(rp.ToString());
            sb.Append("</script>" + Environment.NewLine);
            sb.Append(tm.ToString());
            return(sb);
        }