Example #1
0
        public static void SetHeaderTitle(HtmlHead header, string title)
        {
            if (string.IsNullOrEmpty(title))
                title = AppSettingsManager.GetValue("MetaSiteTitle");

            header.Title = title;
        }
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            ErrorControl errorControl = new ErrorControl();

            if (this.IsAsyncPostBackRequest)
            {
                Controls.Add(errorControl);
            }
            else
            {
                HtmlGenericControl html = new HtmlGenericControl("html");

                HtmlHead head = new HtmlHead();

                HtmlLink link = new HtmlLink();
                link.Href = HttpRuntime.AppDomainAppVirtualPath + "/UIBase/Styles/GlobalReset.css";
                link.Attributes.Add("rel", "stylesheet");
                link.Attributes.Add("type", "text/css");

                head.Controls.Add(link);
                html.Controls.Add(head);

                Controls.Add(html);

                HtmlGenericControl body = new HtmlGenericControl("body");
                body.Attributes.Add("style", "padding: 10px");
                body.Controls.Add(errorControl);
                html.Controls.Add(body);
            }
        }
    public void SetMetaTags(string title, string description, string keywords)
    {
        System.Web.UI.HtmlControls.HtmlHead headTag = (HtmlHead)Page.Header;
        headTag.Title = title;
        HtmlMeta metaTag = new HtmlMeta();

        metaTag.Name    = "Description";
        metaTag.Content = description;
        headTag.Controls.Add(metaTag);
        metaTag         = new HtmlMeta();
        metaTag.Name    = "Keywords";
        metaTag.Content = keywords;
        headTag.Controls.Add(metaTag);
    }
Example #4
0
        public void DontRenderHeadTagIfNestedWithinStandardHeadControl()
        {
            using (new TestWebContext("/", "testpage.aspx"))
            {
                TestPage page = new TestPage(HttpContext.Current);
                HtmlHead htmlHead = new HtmlHead();
                Head head = new Head();
                head.Controls.Add(new LiteralControl("literal child"));
                htmlHead.Controls.Add(head);
                page.Controls.Add(htmlHead);

                // initialize page to force head control initialization
                page.InitRecursive(null);
                string result = page.Render(string.Empty);
                string expect = @"<head>literal child<title></title></head>";
                Assert.AreEqual(expect, result);
            }
        }
Example #5
0
        internal static void SetarCabecalho(HtmlHead htmlHead, HttpRequest request)
        {
            htmlHead.Title = Lite;

            HtmlLink favIcon = new HtmlLink();
            favIcon.Attributes.Add(Rel, ShortcutIcon);
            favIcon.Href = FavIco;
            htmlHead.Controls.Add(favIcon);

            if (request.Browser.Browser == "IE" && (request.Browser.Version == "6.0" || request.Browser.Version == "7.0"))
            {
                HtmlLink link = new HtmlLink();
                link.Href = IeCSS;
                link.Attributes.Add("type", "text/css");
                link.Attributes.Add("rel", "stylesheet");
                htmlHead.Controls.Add(link);
            }
        }
Example #6
0
        public static void AddDefaultMetaTags(HtmlHead header)
        {
            SetHeaderTitle(header, "");

            HtmlMeta meta = new HtmlMeta();
            meta.Name = "title";
            meta.Content = AppSettingsManager.GetValue("MetaSiteTitle");
            header.Controls.Add(meta);

            meta = new HtmlMeta();
            meta.Name = "description";
            meta.Content = AppSettingsManager.GetValue("MetaDescription");
            header.Controls.Add(meta);

            meta = new HtmlMeta();
            meta.Name = "keywords";
            meta.Content = AppSettingsManager.GetValue("MetaKeywords");
            header.Controls.Add(meta);
        }
Example #7
0
 protected override void OnInit(EventArgs e)
 {
     Controls.Add(new LiteralControl("\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.or" +
                 "g/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xh" +
                 "tml\" style=\"overflow: hidden\">\n"));
     HtmlHead head = new HtmlHead();
     Controls.Add(head);
     Controls.Add(new LiteralControl("\n<body>\n    "));
     HtmlForm form = new HtmlForm();
     Controls.Add(form);
     Controls.Add(new LiteralControl("\n</body>\n</html>\n"));
     string controlName = Request.Params["c"];
     if (!(String.IsNullOrEmpty(controlName)))
     {
         Control c = LoadControl(String.Format("~/Controls/Chart_{0}.ascx", controlName));
         form.Controls.Add(c);
     }
     base.OnInit(e);
     EnableViewState = false;
 }
 public void IncludeOn(HtmlHead header)
 {
     string includeStr = this.ResolveUrl(this.url);
     bool alreadyExists = false;
     HtmlHeaderStyleLink aHTCIncludeControl;
     if (header != null)
     {
         foreach (Control control in header.Controls)
         {
             aHTCIncludeControl = control as HtmlHeaderStyleLink;
             if ((aHTCIncludeControl != null) && (String.Compare(aHTCIncludeControl.Url, includeStr, StringComparison.CurrentCultureIgnoreCase) == 0))
                 alreadyExists = true;
         }
         if (!alreadyExists)
         {
             var IncludeCssSection = header.FindControl("IncludeCssSection");
             IncludeCssSection.Controls.Add(this);
         }
     }
 }
Example #9
0
        /// <summary>
        /// Resolves all absolute root paths in header to their relative values.
        /// </summary>
        /// <param name="header">Header to check for relative paths</param>
        public static void ResolveAllRelativeHeadPaths(HtmlHead header)
        {
            string relativePath = header.Page.ResolveUrl("~/");
            if (relativePath.EndsWith("/"))
                relativePath = relativePath.Remove(relativePath.Length - 1);

            foreach (var item in header.Controls)
            {
                if (item is HtmlLink && !(((HtmlLink)item).Href.Contains(relativePath)) && ((HtmlLink)item).Href.StartsWith("/"))
                    ((HtmlLink)item).Href = relativePath + ((HtmlLink)item).Href;
                else if (item is LiteralControl)
                {
                    if (!((LiteralControl)item).Text.Contains("src=\"" + relativePath))
                        ((LiteralControl)item).Text = ((LiteralControl)item).Text.Replace("src=\"/", "src=\"" + relativePath + "/");

                    if (!((LiteralControl)item).Text.Contains("href=\"" + relativePath))
                        ((LiteralControl)item).Text = ((LiteralControl)item).Text.Replace("href=\"/", "href=\"" + relativePath + "/");
                }
            }
        }
Example #10
0
        private void InitControls()
        {
            _main = new Panel();
            _main.ID = "mainPanel";

            Controls.Add(new LiteralControl("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine));
            Controls.Add(new LiteralControl("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">" + Environment.NewLine));
            _head = new HtmlHead();
            _head.Title = _titleText;
            _head.Controls.Add(GetEncodingMeta());
            
            HtmlLink cssLink = new HtmlLink();
            cssLink.ID = "mainCSS";
            cssLink.Attributes.Add("rel", "stylesheet");
            cssLink.Attributes.Add("type", "text/css");
            cssLink.Attributes.Add("href", ClientScript.GetWebResourceUrl(GetType(), "dk.nita.saml20.Protocol.Resources.DefaultStyle.css"));
            _head.Controls.Add(cssLink);

            Controls.Add(_head);
            Controls.Add(new LiteralControl("<body>"));

            _body = new Panel();
            _body.ID = "bodyPanel";

            _header = new Panel();
            _header.ID = "headerPanel";

            _footer = new Panel();
            _footer.ID = "footerPanel";            

            _main.Controls.Add(_header);
            _main.Controls.Add(_body);
            _main.Controls.Add(_footer);

            Controls.Add(_main);

            Controls.Add(new LiteralControl(Environment.NewLine + "</body>" + Environment.NewLine + "</html>"));
        }
        /// <summary>
        /// Gets the ASP.Net page that will serve html to user agent.
        /// </summary>
        /// <returns>The Page.</returns>
        public Page GetPage()
        {
            if (_request == null && _response == null)
            {
                throw new InvalidOperationException("A response or request message MUST be specified before generating the page.");
            }

            var msg = _request ?? _response;

            var p = new Page
                        {
                            EnableViewState = false,
                            EnableViewStateMac = false
                        };

            p.Controls.Add(new LiteralControl("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine));
            p.Controls.Add(new LiteralControl("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">" + Environment.NewLine));

            var head = new HtmlHead { Title = "SAML2.0 POST binding" };
            p.Controls.Add(head);

            p.Controls.Add(new LiteralControl(Environment.NewLine + "<body onload=\"document.forms[0].submit()\">" + Environment.NewLine));
            p.Controls.Add(new LiteralControl("<noscript><p><strong>Note:</strong> Since your browser does not support JavaScript, you must press the Continue button once to proceed.</p></noscript>"));

            p.Controls.Add(new LiteralControl("<form action=\"" + _destinationEndpoint.Url + "\" method=\"post\"><div>"));

            if (!string.IsNullOrEmpty(RelayState))
            {
                var relayStateHidden = new HtmlInputHidden
                                           {
                                               ID = "RelayState",
                                               Name = "RelayState",
                                               Value = RelayState
                                           };
                p.Controls.Add(relayStateHidden);
            }

            var action = new HtmlInputHidden
                             {
                                 Name = Enum.GetName(typeof(SamlActionType), Action),
                                 ID = Enum.GetName(typeof(SamlActionType), Action),
                                 Value = Convert.ToBase64String(Encoding.UTF8.GetBytes(msg))
                             };
            p.Controls.Add(action);

            p.Controls.Add(new LiteralControl("<noscript><div><input type=\"submit\" value=\"Continue\"/></div></noscript>"));
            p.Controls.Add(new LiteralControl("</div></form>"));
            p.Controls.Add(new LiteralControl(Environment.NewLine + "</body>" + Environment.NewLine + "</html>"));

            return p;
        }
Example #12
0
    private void LoopTextboxes(ControlCollection controlCollection)
    {
        int     langId = Convert.ToInt32(Session["LanguageId"]);
        DataSet ds     = _BOUtility.GetLanguageDescription(langId);



        foreach (Control control in controlCollection)
        {
            if (control is TextBox)
            {
                string text  = ((TextBox)control).ID;
                string place = (((TextBox)control).FindControl(text) as TextBox).Text;



                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dtlRow in ds.Tables[0].Rows)
                    {
                        if (dtlRow["Label"].ToString() == text)
                        {
                            string PreviousLabel      = dtlRow["Label"].ToString();
                            string LatestlabelDescrip = dtlRow["LabelDescription"].ToString();

                            ((TextBox)control).Text = PreviousLabel.Replace(PreviousLabel, LatestlabelDescrip);
                        }
                    }
                }
            }
            if (control is DropDownList)
            {
                string text = ((DropDownList)control).ID;

                string place = (((DropDownList)control).FindControl(text) as DropDownList).Text;



                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dtlRow in ds.Tables[0].Rows)
                    {
                        if (dtlRow["Label"].ToString() == text)
                        {
                            string PreviousLabel      = dtlRow["Label"].ToString();
                            string LatestlabelDescrip = dtlRow["LabelDescription"].ToString();

                            ((DropDownList)control).Text = PreviousLabel.Replace(PreviousLabel, LatestlabelDescrip);
                        }
                    }
                }
            }

            if (control is Button)
            {
                string id   = ((Button)control).ID;
                string text = ((Button)control).Text;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dtlRow in ds.Tables[0].Rows)
                    {
                        if (dtlRow["Label"].ToString() == text)
                        {
                            string PreviousLabel      = dtlRow["Label"].ToString();
                            string LatestlabelDescrip = dtlRow["LabelDescription"].ToString();

                            ((Button)control).Text = LatestlabelDescrip;
                        }
                    }
                }
            }


            if (control is Label)
            {
                string id   = ((Label)control).ID;
                string text = ((Label)control).Text;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dtlRow in ds.Tables[0].Rows)
                    {
                        if (dtlRow["Label"].ToString() == text)
                        {
                            string PreviousLabel      = dtlRow["Label"].ToString();
                            string LatestlabelDescrip = dtlRow["LabelDescription"].ToString();

                            ((Label)control).Text = LatestlabelDescrip;
                        }
                    }
                }
            }


            System.Web.UI.HtmlControls.HtmlHead chk = control as System.Web.UI.HtmlControls.HtmlHead;

            if (chk != null)
            {
                //string text = chk.InnerHtml
            }



            //Label mylabel;
            //if (control.GetType() == typeof(Label)) //or any other logic
            //{
            //    mylabel = (Label)control;
            //    mylabel.BackColor = Color.Red;
            //}


            if (control.Controls != null)
            {
                LoopTextboxes(control.Controls);
            }
        }
    }
Example #13
0
        private void AddScriptFiles(HtmlHead head)
        {
            if (head == null)
                throw new ArgumentNullException();

            // Build up the script references, starting with the IE HTML5 shim.
            var isDebug = Utils.IsDebugEnabled;

            string script = String.Format(CultureInfo.InvariantCulture, @"
            <!--[if lt IE 9]>
            <script src='//html5shiv.googlecode.com/svn/trunk/html5.js'></script>
            <script>window.html5 || document.write('<script src=""{0}"">\x3C/script>')
            </script>
            <![endif]-->
            ",
             isDebug ? Utils.GetUrl("/script/debug/html5shiv.js") : Utils.GetUrl("/script/html5shiv.min.js"));

            // Add jQuery reference. Fall back to a local copy of jquery.js if the one specified
            // in the setting does not load for any reason (e.g. CDN is unavailable).
            if (!String.IsNullOrEmpty(AppSetting.Instance.JQueryScriptPath))
            {
                script += String.Format(CultureInfo.InvariantCulture, @"
            <script src='{0}'></script>
            <script>window.jQuery || document.write('<script src=""{1}"">\x3C/script>')
            </script>",
            GetJQueryPath(),
            isDebug ? Utils.GetUrl("/script/debug/jquery.js") : Utils.GetUrl("/script/jquery.min.js")
             );
            }

            // Add jQuery Migrate Plugin reference. Fall back to a local copy if the one specified
            // in the setting does not load for any reason (e.g. CDN is unavailable).
            if (!String.IsNullOrEmpty(AppSetting.Instance.JQueryMigrateScriptPath))
            {
                script += String.Format(CultureInfo.InvariantCulture, @"
            <script src='{0}'></script>
            <script>jQuery.migrateWarnings || document.write('<script src=""{1}"">\x3C/script>')
            </script>",
            GetJQueryMigratePath(),
            isDebug ? Utils.GetUrl("/script/debug/jquery-migrate.js") : Utils.GetUrl("/script/jquery-migrate.min.js")
             );
            }

            // Add jQuery UI reference. Fall back to a local copy of jquery-ui.min.js if the one
            // specified in the setting does not load for any reason (e.g. CDN is unavailable).
            if (!String.IsNullOrEmpty(AppSetting.Instance.JQueryUiScriptPath))
            {
                script += string.Format(CultureInfo.InvariantCulture, @"
            <script src='{0}'></script>
            <script>window.jQuery.ui || document.write('<script src=""{1}"">\x3C/script>')
            </script>",
             GetJQueryUiPath(),
             isDebug ? Utils.GetUrl("/script/debug/jquery-ui.js") : Utils.GetUrl("/script/jquery-ui.min.js"));
            }

            // Add reference to lib.js
            script += string.Format(CultureInfo.InvariantCulture, @"
            <script src='{0}'></script>
            ",
             isDebug ? Utils.GetUrl("/script/debug/lib.js") : Utils.GetUrl("/script/lib.min.js"));

            // Add reference to gallery.js
            script += string.Format(CultureInfo.InvariantCulture, @"
            <script src='{0}'></script>
            ",
             isDebug ? Utils.GetUrl("/script/debug/gallery.js") : Utils.GetUrl("/script/gallery.min.js"));

            head.Controls.Add(new LiteralControl(script));
        }
Example #14
0
		public void RegisterStyle (Style baseStyle, string className, HtmlHead head)
		{
			if (head == null)
				return;
			if (String.IsNullOrEmpty (className))
				className = IncrementStyleClassName ();
			baseStyle.SetRegisteredCssClass (className);
			head.StyleSheet.CreateStyleRule (baseStyle, Owner, "." + className);
		}
Example #15
0
		public void RegisterStyle (Style baseStyle, Style linkStyle, string className, HtmlHead head)
		{
			if (head == null)
				return;
			
			linkStyle.CopyTextStylesFrom (baseStyle);
			linkStyle.BorderStyle = BorderStyle.None;
			RegisterStyle (linkStyle, className, head);
			RegisterStyle (baseStyle, className, head);
		}
Example #16
0
		public void FillMenuStyle (HtmlHead header, bool dynamic, int menuLevel, SubMenuStyle style)
		{
			Menu owner = Owner;
			if (header == null) {
				Page page = owner.Page;
				header = page != null ? page.Header : null;
			}
			
			SubMenuStyle staticMenuStyle = owner.StaticMenuStyleInternal;
//			MenuItemStyle dynamicMenuItemStyle = owner.DynamicMenuItemStyleInternal;
			SubMenuStyle dynamicMenuStyle = owner.DynamicMenuStyleInternal;
			SubMenuStyleCollection levelSubMenuStyles = owner.LevelSubMenuStylesInternal;
			
			if (header != null) {
				// styles are registered
				if (!dynamic && staticMenuStyle != null) {
					AddCssClass (style, staticMenuStyle.CssClass);
					AddCssClass (style, staticMenuStyle.RegisteredCssClass);
				}
				if (dynamic && dynamicMenuStyle != null) {
					AddCssClass (style, dynamicMenuStyle.CssClass);
					AddCssClass (style, dynamicMenuStyle.RegisteredCssClass);
				}
				if (levelSubMenuStyles != null && levelSubMenuStyles.Count > menuLevel) {
					AddCssClass (style, levelSubMenuStyles [menuLevel].CssClass);
					AddCssClass (style, levelSubMenuStyles [menuLevel].RegisteredCssClass);
				}
			} else {
				// styles are not registered
				if (!dynamic && staticMenuStyle != null)
					style.CopyFrom (staticMenuStyle);
				if (dynamic && dynamicMenuStyle != null)
					style.CopyFrom (dynamicMenuStyle);
				if (levelSubMenuStyles != null && levelSubMenuStyles.Count > menuLevel)
					style.CopyFrom (levelSubMenuStyles [menuLevel]);
			}
		}
Example #17
0
		public override void PreRender (Page page, HtmlHead head, ClientScriptManager csm, string cmenu, StringBuilder script)
		{
			Menu owner = Owner;
			MenuItemStyle staticMenuItemStyle = owner.StaticMenuItemStyleInternal;
			SubMenuStyle staticMenuStyle = owner.StaticMenuStyleInternal;
			MenuItemStyle dynamicMenuItemStyle = owner.DynamicMenuItemStyleInternal;
			SubMenuStyle dynamicMenuStyle = owner.DynamicMenuStyleInternal;
			MenuItemStyleCollection levelMenuItemStyles = owner.LevelMenuItemStyles;
			List<Style> levelMenuItemLinkStyles = owner.LevelMenuItemLinkStyles;
			SubMenuStyleCollection levelSubMenuStyles = owner.LevelSubMenuStylesInternal;
			MenuItemStyle staticSelectedStyle = owner.StaticSelectedStyleInternal;
			MenuItemStyle dynamicSelectedStyle = owner.DynamicSelectedStyleInternal;
			MenuItemStyleCollection levelSelectedStyles = owner.LevelSelectedStylesInternal;
			List<Style> levelSelectedLinkStyles = owner.LevelSelectedLinkStyles;
			Style staticHoverStyle = owner.StaticHoverStyleInternal;
			Style dynamicHoverStyle = owner.DynamicHoverStyleInternal;
			
			if (!csm.IsClientScriptIncludeRegistered (typeof (Menu), "Menu.js")) {
				string url = csm.GetWebResourceUrl (typeof (Menu), "Menu.js");
				csm.RegisterClientScriptInclude (typeof (Menu), "Menu.js", url);
			}
			
			script.AppendFormat (onPreRenderScript,
					     cmenu,
					     page.IsMultiForm ? page.theForm : "window",
					     ClientScriptManager.GetScriptLiteral (owner.DisappearAfter),
					     ClientScriptManager.GetScriptLiteral (owner.Orientation == Orientation.Vertical));

			if (owner.DynamicHorizontalOffset != 0)
				script.Append (String.Concat (cmenu, ".dho = ", ClientScriptManager.GetScriptLiteral (owner.DynamicHorizontalOffset), ";\n"));
			if (owner.DynamicVerticalOffset != 0)
				script.Append (String.Concat (cmenu, ".dvo = ", ClientScriptManager.GetScriptLiteral (owner.DynamicVerticalOffset), ";\n"));

			// The order in which styles are defined matters when more than one class
			// is assigned to an element
			RegisterStyle (owner.PopOutBoxStyle, head);
			RegisterStyle (owner.ControlStyle, owner.ControlLinkStyle, head);
			
			if (staticMenuItemStyle != null)
				RegisterStyle (owner.StaticMenuItemStyle, owner.StaticMenuItemLinkStyle, head);

			if (staticMenuStyle != null)
				RegisterStyle (owner.StaticMenuStyle, head);
			
			if (dynamicMenuItemStyle != null)
				RegisterStyle (owner.DynamicMenuItemStyle, owner.DynamicMenuItemLinkStyle, head);

			if (dynamicMenuStyle != null)
				RegisterStyle (owner.DynamicMenuStyle, head);

			if (levelMenuItemStyles != null && levelMenuItemStyles.Count > 0) {
				levelMenuItemLinkStyles = new List<Style> (levelMenuItemStyles.Count);
				foreach (Style style in levelMenuItemStyles) {
					Style linkStyle = new Style ();
					levelMenuItemLinkStyles.Add (linkStyle);
					RegisterStyle (style, linkStyle, head);
				}
			}
		
			if (levelSubMenuStyles != null)
				foreach (Style style in levelSubMenuStyles)
					RegisterStyle (style, head);

			if (staticSelectedStyle != null)
				RegisterStyle (staticSelectedStyle, owner.StaticSelectedLinkStyle, head);
			
			if (dynamicSelectedStyle != null)
				RegisterStyle (dynamicSelectedStyle, owner.DynamicSelectedLinkStyle, head);

			if (levelSelectedStyles != null && levelSelectedStyles.Count > 0) {
				levelSelectedLinkStyles = new List<Style> (levelSelectedStyles.Count);
				foreach (Style style in levelSelectedStyles) {
					Style linkStyle = new Style ();
					levelSelectedLinkStyles.Add (linkStyle);
					RegisterStyle (style, linkStyle, head);
				}
			}
			
			if (staticHoverStyle != null) {
				if (head == null)
					throw new InvalidOperationException ("Using Menu.StaticHoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
				RegisterStyle (staticHoverStyle, owner.StaticHoverLinkStyle, head);
				script.Append (String.Concat (cmenu, ".staticHover = ", ClientScriptManager.GetScriptLiteral (staticHoverStyle.RegisteredCssClass), ";\n"));
				script.Append (String.Concat (cmenu, ".staticLinkHover = ", ClientScriptManager.GetScriptLiteral (owner.StaticHoverLinkStyle.RegisteredCssClass), ";\n"));
			}
			
			if (dynamicHoverStyle != null) {
				if (head == null)
					throw new InvalidOperationException ("Using Menu.DynamicHoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
				RegisterStyle (dynamicHoverStyle, owner.DynamicHoverLinkStyle, head);
				script.Append (String.Concat (cmenu, ".dynamicHover = ", ClientScriptManager.GetScriptLiteral (dynamicHoverStyle.RegisteredCssClass), ";\n"));
				script.Append (String.Concat (cmenu, ".dynamicLinkHover = ", ClientScriptManager.GetScriptLiteral (owner.DynamicHoverLinkStyle.RegisteredCssClass), ";\n"));
			}
		}
Example #18
0
        /// <summary>
        /// Writes the HTML Head element.  Adds site stylesheet.
        /// </summary>
        protected virtual void RenderHtmlHead()
        {
            _head = new HtmlHead();

            HtmlTitle title = new HtmlTitle();
            title.Text = _title;
            _head.Controls.Add(title);

            HtmlLink logEmCSS = new HtmlLink();
            logEmCSS.Attributes.Add("rel", "stylesheet");
            logEmCSS.Attributes.Add("type", "text/css");
            logEmCSS.Attributes.Add("href", ExtractBaseLogEmUrl(Context.Request.Url.Segments) + "stylesheet");
            _head.Controls.Add(logEmCSS);

            Page.Controls.Add(_head);

            _head.RenderControl(_writer);
            _writer.WriteLine();
        }
		/// <summary>
		/// 如果请求是提醒对话框的,则处理该请求,显示提醒对话框的内容
		/// </summary>
		private void DoNotifyDialog()
		{
			if (HttpContext.Current.Request.RequestType == "POST")
			{
				string taskID = HttpContext.Current.Request.QueryString["taskID"];
				string taskSource = WebUtility.GetRequestFormString("taskSource", "userTask");

				if (string.IsNullOrEmpty(taskID) == false && GetAutoTransferToCompletedTask())
				{
					UserTask task = new UserTask();
					task.TaskID = taskID;
					UserTaskCollection tasks = new UserTaskCollection();
					tasks.Add(task);
					if (taskSource == "userTask")
						UserTaskAdapter.Instance.DeleteUserTasks(tasks);
					else
						UserTaskAdapter.Instance.DeleteUserAccomplishedTasks(tasks);
				}

				SaveAutoTransferToCompletedTaskFlag();

				//WebUtility.ResponseRefreshParentWindowScriptBlock();
				HttpContext.Current.Response.Write(ExtScriptHelper.GetRefreshBridgeScript());
				WebUtility.ResponseTimeoutScriptBlock("top.close();", ExtScriptHelper.DefaultResponseTimeout);

				HttpContext.Current.Response.End();
			}
			else
			{
				Page page = new Page();

				HtmlGenericControl html = new HtmlGenericControl("html");
				WebUtility.SetCurrentPage(page);
				page.Controls.Add(html);

				HtmlHead head = new HtmlHead();
				html.Controls.Add(head);

				HtmlTitle title = new HtmlTitle();
				title.Text = Translator.Translate(Define.DefaultCulture, "提醒消息");
				head.Controls.Add(title);

				HtmlGenericControl body = new HtmlGenericControl("body");
				html.Controls.Add(body);

				WebUtility.AttachPageModules(page);

				string temmplate = GetNotifyDialogHtml();
				string pageHtml = InitNotifyDialogPage(temmplate);

				body.Controls.Add(new LiteralControl(pageHtml));

				((IHttpHandler)page).ProcessRequest(HttpContext.Current);

				HttpContext.Current.Response.End();
			}
		}
Example #20
0
		private void SetupHeadControl(HtmlHead head)
		{
			if (String.IsNullOrEmpty(head.Title))
				head.Title = PageTitle;

			// Add CSS links to the header.
			head.Controls.Add(MakeStyleSheetControl(Util.GetUrl("/styles/gallery.css")));
			head.Controls.Add(MakeStyleSheetControl(Util.GetUrl("/styles/ca_styles.css")));
		}
Example #21
0
 protected override void OnInit(EventArgs e)
 {
     Controls.Add(new LiteralControl("\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.or" +
                 "g/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xh" +
                 "tml\" style=\"overflow: hidden\">\n"));
     HtmlHead head = new HtmlHead();
     Controls.Add(head);
     head.Controls.Add(new LiteralControl(@"
     <script type=""text/javascript"">
     function pageLoad() {
     var m = location.href.match(/(\?|&)id=(.+?)(&|$)/);
     if (!(parent && parent.window.Web) || !m) return;
     var elem = parent.window.$get(m[2]);
     if (!elem) return;
     if (typeof (FieldEditor_SetValue) !== ""undefined"")
         FieldEditor_SetValue(elem.value);
     else
         alert('The field editor does not implement ""FieldEditor_SetValue"" function.');
     if (typeof (FieldEditor_GetValue) !== ""undefined"")
         parent.window.Web.DataView.Editors[elem.id] = { 'GetValue': FieldEditor_GetValue, 'SetValue': FieldEditor_SetValue };
     else
         alert('The field editor does not implement ""FieldEditor_GetValue"" function.');
     }
     </script>
     "));
     head.Controls.Add(new LiteralControl("\n    <style type=\"text/css\">\n        .ajax__htmleditor_editor_container\n        {" +
                 "\n            border-width:0px!important;\n        }\n\n        .ajax__htmleditor_ed" +
                 "itor_bottomtoolbar\n        {\n            padding-top:2px!important;\n        }\n  " +
                 "  </style>"));
     Controls.Add(new LiteralControl("\n<body style=\"margin: 0px; padding: 0px; background-color: #fff;\">\n"));
     HtmlForm form = new HtmlForm();
     Controls.Add(form);
     ScriptManager sm = new ScriptManager();
     sm.ScriptMode = ScriptMode.Release;
     form.Controls.Add(sm);
     string controlName = Request.Params["control"];
     Control c = null;
     if (!(String.IsNullOrEmpty(controlName)))
     {
         try
         {
             c = LoadControl(String.Format("~/Controls/{0}.ascx", controlName));
         }
         catch (Exception )
         {
         }
         if (c != null)
         {
             object[] editorAttributes = c.GetType().GetCustomAttributes(typeof(AquariumFieldEditorAttribute), true);
             if (editorAttributes.Length == 0)
                 c = null;
         }
         else
             if (controlName == "RichEditor")
             {
             }
     }
     if (c == null)
         throw new HttpException(404, String.Empty);
     else
     {
         form.Controls.Add(c);
         if (!((c.GetType() == typeof(System.Web.UI.UserControl))))
             this.ClientScript.RegisterClientScriptBlock(GetType(), "ClientScripts", String.Format("function FieldEditor_GetValue(){{return $find(\'{0}\').get_content();}}\nfunction Fi" +
                         "eldEditor_SetValue(value) {{$find(\'{0}\').set_content(value);}}", c.ClientID), true);
     }
     Controls.Add(new LiteralControl("\n\n</body>\n</html>"));
     base.OnInit(e);
     EnableViewState = false;
 }
        private static HtmlHead BuildHtmlHeadControl(this XhtmlDocument xhtmlDocument, IXElementToControlMapper controlMapper)
        {
            HtmlHead headControl = new HtmlHead();

            xhtmlDocument.MergeToHeadControl(headControl, controlMapper);

            return headControl;
        }
        internal static void MergeToHeadControl(this XhtmlDocument xhtmlDocument, HtmlHead headControl, IXElementToControlMapper controlMapper)
        {
            XElement headSource = xhtmlDocument.Head;

            if (headSource == null) return;

            CopyAttributes(headSource, headControl);

            XElement titleElement = headSource.Elements(Namespaces.Xhtml + "title").LastOrDefault();
            if (titleElement != null)
            {
                HtmlTitle existingControl = headControl.Controls.OfType<HtmlTitle>().FirstOrDefault();

                if (existingControl != null)
                {
                    headControl.Controls.Remove(existingControl);
                }

                // NOTE: we aren't using headControl.Title property since it adds "<title>" tag as the last one
                headControl.Controls.AddAt(0, new HtmlTitle { Text = HttpUtility.HtmlEncode(titleElement.Value) });
            }

            var metaTags = headSource.Elements().Where(f => f.Name == Namespaces.Xhtml + "meta");
            int metaTagPosition = Math.Min(1, headControl.Controls.Count);
            foreach (var metaTag in metaTags)
            {
                HtmlMeta metaControl = new HtmlMeta();
                foreach (var attribute in metaTag.Attributes())
                {
                    metaControl.Attributes.Add(attribute.Name.LocalName, attribute.Value);
                }
                headControl.Controls.AddAt(metaTagPosition++, metaControl);
            }

            ExportChildNodes(headSource.Nodes().Where(f => ((f is XElement) == false || ((XElement)f).Name != Namespaces.Xhtml + "title" && ((XElement)f).Name != Namespaces.Xhtml + "meta")), headControl, controlMapper);

            headControl.RemoveDuplicates();
        }
Example #24
0
			public OwnerContext (BaseMenuRenderer container)
			{
				if (container == null)
					throw new ArgumentNullException ("container");

				this.container = container;
				Menu owner = container.Owner;
				Page page = owner.Page;

				Header = page != null ? page.Header : null;
				ClientID = owner.ClientID;
				IsVertical = owner.Orientation == Orientation.Vertical;
				StaticSubMenuIndent = owner.StaticSubMenuIndent;
				SelectedItem = owner.SelectedItem;
				ControlLinkStyle = owner.ControlLinkStyle;
				StaticDisplayLevels = owner.StaticDisplayLevels;
				StaticMenuItemStyle = owner.StaticMenuItemStyleInternal;
				DynamicMenuItemStyle = owner.DynamicMenuItemStyleInternal;
				LevelMenuItemStyles = owner.LevelMenuItemStyles;
			}
Example #25
0
		public abstract void PreRender (Page page, HtmlHead head, ClientScriptManager csm, string cmenu, StringBuilder script);
Example #26
0
 // Meta Tags for Default Page
 public static void META_StaticPage(System.Web.UI.Page _pg, System.Web.UI.HtmlControls.HtmlHead _hd, string title, string description, string imageurl, string url)
 {
     _pg.Title = title + " - " + Site_Settings.Website_Title;
     PAGE_META(_hd, "", description);
     FB_META(_hd, title, description, imageurl, url);
 }
Example #27
0
		public void RegisterStyle (Style baseStyle, Style linkStyle, HtmlHead head)
		{
			RegisterStyle (baseStyle, linkStyle, null, head);
		}
Example #28
0
        /// <summary>
        /// Initializes the controls.
        /// </summary>
        private void InitControls()
        {
            MainPanel = new Panel { ID = "mainPanel" };

            Controls.Add(new LiteralControl("<!DOCTYPE html>" + Environment.NewLine + "<html>" + Environment.NewLine));

            Head = new HtmlHead { Title = TitleText };
            Head.Controls.Add(GetEncodingMetaTag());

            Controls.Add(Head);
            Controls.Add(new LiteralControl("<body>"));

            HeaderPanel = new Panel { ID = "headerPanel" };
            BodyPanel = new Panel { ID = "bodyPanel" };
            FooterPanel = new Panel { ID = "footerPanel" };

            MainPanel.Controls.Add(HeaderPanel);
            MainPanel.Controls.Add(BodyPanel);
            MainPanel.Controls.Add(FooterPanel);

            Controls.Add(MainPanel);

            Controls.Add(new LiteralControl(Environment.NewLine + "</body>" + Environment.NewLine + "</html>"));
        }
Example #29
0
		public void RegisterStyle (Style baseStyle, HtmlHead head)
		{
			RegisterStyle (baseStyle, (string)null, head);
		}
Example #30
0
        /// <summary>
        /// Set up the items within the head portion of the HTML page. Specifically, assign the title tag and add links to the 
        /// CSS and jQuery files.
        /// </summary>
        /// <param name="head">The head portion of the current HTML page.</param>
        private void SetupHeadControl(HtmlHead head)
        {
            if (String.IsNullOrEmpty(head.Title))
                head.Title = PageTitle;

            // Add CSS links to the header, but only if they haven't already been added by another Gallery control on the page.
            object cssFilesAddedObject = HttpContext.Current.Items["GSP_CssFilesAdded"];
            bool cssFilesAdded = false;
            bool foundCssFilesAddedVar = ((cssFilesAddedObject != null) && Boolean.TryParse(cssFilesAddedObject.ToString(), out cssFilesAdded));
            if (!foundCssFilesAddedVar || (!cssFilesAdded))
            {
                foreach (string cssPath in GetCssPaths())
                {
                    head.Controls.Add(MakeStyleSheetControl(cssPath));
                }

                HttpContext.Current.Items["GSP_CssFilesAdded"] = bool.TrueString;
            }

            AddjQuery();
        }
Example #31
0
	internal void SetHeader (HtmlHead header)
	{
		htmlHeader = header;
		if (header == null)
			return;
		
		if (_title != null) {
			htmlHeader.Title = _title;
			_title = null;
		}
#if NET_4_0
		if (_metaDescription != null) {
			htmlHeader.Description = _metaDescription;
			_metaDescription = null;
		}

		if (_metaKeywords != null) {
			htmlHeader.Keywords = _metaKeywords;
			_metaKeywords = null;
		}
#endif
	}
 /// <summary>
 /// 添加样式文件。
 /// </summary>
 /// <param name="head">HtmlHead。</param>
 protected virtual void AddCssStyle(HtmlHead head)
 {
     if (this.ModulePage != null && head != null)
     {
         string[] styles = this.ModulePage.WebCssPaths;
         if (styles != null && styles.Length > 0)
         {
             foreach (string href in styles)
             {
                 if (!string.IsNullOrEmpty(href))
                 {
                     HtmlLink styleLink = new HtmlLink();
                     styleLink.Href = this.Page.ResolveUrl(href);
                     styleLink.Attributes.Add("rel", "stylesheet");
                     styleLink.Attributes.Add("type", "text/css");
                     head.Controls.Add(styleLink);
                 }
             }
         }
     }
 }
		private static void InitNewPageContent(Page page, Control ctr)
		{
			HtmlGenericControl html = new HtmlGenericControl("html");
			LiteralControl literal = new LiteralControl("<!DOCTYPE html>");
			page.Controls.Add(literal);

			//html.Attributes["xmlns"] = "http://www.w3.org/1999/xhtml";
			HttpContext.Current.SetCurrentPage(page);

			page.Items[PageExtension.PageRenderControlItemKey] = ctr;
			page.Controls.Add(html);

			HtmlHead head = new HtmlHead();

			html.Controls.Add(head);
			HtmlGenericControl body = new HtmlGenericControl("body");
			html.Controls.Add(body);

			HtmlForm form = new HtmlForm();
			form.ID = "pageForm";
			form.Controls.Add(ctr);
			body.Controls.Add(form);

			page.PreRenderComplete += new EventHandler(dialogPage_PreRenderComplete);
		}
 public StyleSheetInternal(HtmlHead owner)
 {
     this._owner = owner;
 }