当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTextWriter.WriteEncodedText方法代码示例

本文整理汇总了C#中HtmlTextWriter.WriteEncodedText方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.WriteEncodedText方法的具体用法?C# HtmlTextWriter.WriteEncodedText怎么用?C# HtmlTextWriter.WriteEncodedText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlTextWriter的用法示例。


在下文中一共展示了HtmlTextWriter.WriteEncodedText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderBulletText

 // Writes the text of each bullet according to the list's display mode.
 protected virtual void RenderBulletText (ListItemCollection items, int index, HtmlTextWriter writer) {
     switch (Control.DisplayMode) {
         case BulletedListDisplayMode.Text:
             writer.WriteEncodedText(items[index].Text);
             writer.WriteBreak();
             break;
         case BulletedListDisplayMode.HyperLink:
             // 
             string targetURL = Control.ResolveClientUrl(items[index].Value);
             if (items[index].Enabled) {
                 PageAdapter.RenderBeginHyperlink(writer, targetURL, true /* encode */, items[index].Text);
                 writer.Write(items[index].Text);
                 PageAdapter.RenderEndHyperlink(writer);
             } else {
                 writer.WriteEncodedText(items[index].Text);
             }
             writer.WriteBreak();
             break;
         case BulletedListDisplayMode.LinkButton:
             if (items[index].Enabled) {
                 // 
                 PageAdapter.RenderPostBackEvent(writer, Control.UniqueID, index.ToString(CultureInfo.InvariantCulture),
                                                     items[index].Text, items[index].Text);
             } else {
                 writer.WriteEncodedText(items[index].Text);
             }
             writer.WriteBreak();
             break;
         default:
             Debug.Assert(false, "Invalid BulletedListDisplayMode");
             break;
     }
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:34,代码来源:WmlBulletedListAdapter.cs

示例2: ShowUpdateForm

        /// <summary>
        /// Generates a SPARQL Update Form
        /// </summary>
        /// <param name="context">HTTP Context</param>
        protected virtual void ShowUpdateForm(HttpContext context)
        {
            //Set Content Type
            context.Response.Clear();
            context.Response.ContentType = "text/html";

            //Get a HTML Text Writer
            HtmlTextWriter output = new HtmlTextWriter(new StreamWriter(context.Response.OutputStream));

            //Page Header
            output.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
            output.RenderBeginTag(HtmlTextWriterTag.Html);
            output.RenderBeginTag(HtmlTextWriterTag.Head);
            output.RenderBeginTag(HtmlTextWriterTag.Title);
            output.WriteEncodedText("SPARQL Update Interface");
            output.RenderEndTag();
            //Add Stylesheet
            if (!this._config.Stylesheet.Equals(String.Empty))
            {
                output.AddAttribute(HtmlTextWriterAttribute.Href, this._config.Stylesheet);
                output.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                output.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
                output.RenderBeginTag(HtmlTextWriterTag.Link);
                output.RenderEndTag();
            }
            output.RenderEndTag();


            //Header Text
            output.RenderBeginTag(HtmlTextWriterTag.Body);
            output.RenderBeginTag(HtmlTextWriterTag.H3);
            output.WriteEncodedText("SPARQL Update Interface");
            output.RenderEndTag();

            //Query Form
            output.AddAttribute(HtmlTextWriterAttribute.Name, "sparqlUpdate");
            output.AddAttribute("method", "get");
            output.AddAttribute("action", context.Request.Path);
            output.RenderBeginTag(HtmlTextWriterTag.Form);

            if (!this._config.IntroductionText.Equals(String.Empty))
            {
                output.RenderBeginTag(HtmlTextWriterTag.P);
                output.Write(this._config.IntroductionText);
                output.RenderEndTag();
            }

            output.WriteEncodedText("Update");
            output.WriteBreak();
            output.AddAttribute(HtmlTextWriterAttribute.Name, "update");
            output.AddAttribute(HtmlTextWriterAttribute.Rows, "15");
            output.AddAttribute(HtmlTextWriterAttribute.Cols, "100");
            output.RenderBeginTag(HtmlTextWriterTag.Textarea);
            output.WriteEncodedText(this._config.DefaultUpdate);
            output.RenderEndTag();
            output.WriteBreak();

            //output.WriteEncodedText("Default Graph URI: ");
            //output.AddAttribute(HtmlTextWriterAttribute.Name, "default-graph-uri");
            //output.AddAttribute(HtmlTextWriterAttribute.Type, "text");
            //output.AddAttribute(HtmlTextWriterAttribute.Size, "100");
            //output.AddAttribute(HtmlTextWriterAttribute.Value, this._config.DefaultGraphURI);
            //output.RenderBeginTag(HtmlTextWriterTag.Input);
            //output.RenderEndTag();
            //output.WriteBreak();

            output.AddAttribute(HtmlTextWriterAttribute.Type, "submit");
            output.AddAttribute(HtmlTextWriterAttribute.Value, "Perform Update");
            output.RenderBeginTag(HtmlTextWriterTag.Input);
            output.RenderEndTag();

            output.RenderEndTag(); //End Form

            //End of Page
            output.RenderEndTag(); //End Body
            output.RenderEndTag(); //End Html

            output.Flush();
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:83,代码来源:BaseSparqlUpdateHandler.cs

示例3: Render

		public override void Render(string uniqueId, string separatorHtml, HtmlTextWriter writer)
		{
			if (property == null || property.Value == null)
				return;
			writer.WriteEncodedText((bool)property.Value ? BXLoc.GetModuleMessage("main", "Kernel.Yes") : BXLoc.GetModuleMessage("main", "Kernel.No"));
		}
开发者ID:mrscylla,项目名称:volotour.ru,代码行数:6,代码来源:customtype.ascx.cs

示例4: GenerateOutput

        /// <summary>
        /// Internal method which generates the HTML Output for the Sparql Results
        /// </summary>
        /// <param name="results"></param>
        /// <param name="output"></param>
        private void GenerateOutput(SparqlResultSet results, TextWriter output)
        {
            HtmlTextWriter writer = new HtmlTextWriter(output);
            QNameOutputMapper qnameMapper = new QNameOutputMapper(this._namespaces != null ? this._namespaces : new NamespaceMapper(true));

            //Page Header
            writer.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
            writer.RenderBeginTag(HtmlTextWriterTag.Html);
            writer.RenderBeginTag(HtmlTextWriterTag.Head);
            writer.RenderBeginTag(HtmlTextWriterTag.Title);
            writer.WriteEncodedText("SPARQL Query Results");
            writer.RenderEndTag();
            if (!this.Stylesheet.Equals(String.Empty))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, this.Stylesheet);
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                writer.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
                writer.RenderBeginTag(HtmlTextWriterTag.Link);
                writer.RenderEndTag();
            }
            //TODO: Add <meta> for charset?
            writer.RenderEndTag();

            //Start Body
            writer.RenderBeginTag(HtmlTextWriterTag.Body);

            if (results.ResultsType == SparqlResultsType.VariableBindings)
            {
                //Create a Table for the results
                writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
                writer.RenderBeginTag(HtmlTextWriterTag.Table);

                //Create a Table Header with the Variable Names
                writer.RenderBeginTag(HtmlTextWriterTag.Thead);
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                foreach (String var in results.Variables)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.WriteEncodedText(var);
                    writer.RenderEndTag();
                }

                writer.RenderEndTag();
                writer.RenderEndTag();
#if !NO_WEB
                writer.WriteLine();
#endif

                //Create a Table Body for the Results
                writer.RenderBeginTag(HtmlTextWriterTag.Tbody);

                //Create a Column for each Binding
                foreach (SparqlResult result in results)
                {
                    //Start Row
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    foreach (String var in results.Variables)
                    {
                        //Start Column
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);

                        if (result.HasValue(var))
                        {
                            INode value = result[var];

                            if (value != null)
                            {
                                switch (value.NodeType)
                                {
                                    case NodeType.Blank:
                                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClassBlankNode);
                                        writer.RenderBeginTag(HtmlTextWriterTag.Span);
                                        writer.WriteEncodedText(value.ToString());
                                        writer.RenderEndTag();
                                        break;

                                    case NodeType.Literal:
                                        ILiteralNode lit = (ILiteralNode)value;
                                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClassLiteral);
                                        writer.RenderBeginTag(HtmlTextWriterTag.Span);
                                        if (lit.DataType != null)
                                        {
                                            writer.WriteEncodedText(lit.Value);
                                            writer.RenderEndTag();
                                            writer.WriteEncodedText("^^");
                                            writer.AddAttribute(HtmlTextWriterAttribute.Href, this._formatter.FormatUri(lit.DataType.ToString()));
                                            writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClassDatatype);
                                            writer.RenderBeginTag(HtmlTextWriterTag.A);
                                            writer.WriteEncodedText(lit.DataType.ToString());
                                            writer.RenderEndTag();
                                        }
                                        else
                                        {
//.........这里部分代码省略.........
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:101,代码来源:SPARQLHTMLWriter.cs

示例5: RenderStaticText

 /// <summary>
 /// Renders the static text.
 /// </summary>
 /// <param name="w">The w.</param>
 protected virtual void RenderStaticText(HtmlTextWriter w)
 {
     string text = Text;
     string formatAB;
     if (TextAlign == TextAlign.Right)
     {
         text = (!string.IsNullOrEmpty(text) ? HttpContextEx.EmptyHtml + Text : string.Empty);
         formatAB = "[{0}]{1}";
     }
     else
     {
         text = (!string.IsNullOrEmpty(text) ? Text + HttpContextEx.EmptyHtml : string.Empty);
         formatAB = "{1}[{0}]";
     }
     w.RenderBeginTag(HtmlTextWriterTag.Span);
     w.WriteEncodedText(string.Format(formatAB, (Checked ? "X" : "-"), text));
     w.RenderEndTag();
 }
开发者ID:BclEx,项目名称:BclEx-Web,代码行数:22,代码来源:CheckBoxEx.cs


注:本文中的HtmlTextWriter.WriteEncodedText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。