Exemplo n.º 1
0
        protected override void OnPreRender(EventArgs e)
        {
            SharedBasePage requestPage = Page as SharedBasePage;

            base.OnPreRender(e);
            if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "script"))
            {
                string prefix =
                    String.Format("var ct_img_expanded = '{0}';\nvar ct_img_collapsed = '{1}';",
                                  requestPage.GetThemedImageUrl("outlinedown"),
                                  requestPage.GetThemedImageUrl("outlinearrow"));

                string script;
                using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".CategoryListJS.txt")))
                {
                    script = rs.ReadToEnd();
                }
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script",
                                                            String.Format("<script type=\"text/javascript\">\n<!--\n{0}\n{1}\n// --></script>", prefix, script));
            }
            if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "style"))
            {
                string script;
                using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".CategoryListCSS.txt")))
                {
                    script = rs.ReadToEnd();
                }
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "style", "");
                requestPage.InsertInPageHeader(String.Format("<style type=\"text/css\">{0}</style>", script));
            }
        }
Exemplo n.º 2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            SharedBasePage requestPage = Page as SharedBasePage;

            if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "script"))
            {
                string script;
                using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".SearchHighlightJS.txt")))
                {
                    script = rs.ReadToEnd();
                }

                script = script.Replace("<%siteRoot%>", requestPage.SiteConfig.Root);

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script",
                                                            String.Format("<script type=\"text/javascript\">\n<!--\n{0}\n// -->\n</script>", script));
            }

            if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "style"))
            {
                string script;
                using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".SearchHighlightCSS.txt")))
                {
                    script = rs.ReadToEnd();
                }
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "style", "");
                requestPage.InsertInPageHeader(String.Format("<style type=\"text/css\">{0}</style>", script));
            }
        }