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


C# Literal.ToString方法代码示例

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


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

示例1: btnShow_Click

        protected void btnShow_Click(object sender, EventArgs e)
        {
            //I need to dynamically create the instance with code, for instance table[i] needs to be systematically created
            //int i = 0;
            System.Web.UI.HtmlControls.HtmlTable Htable = new HtmlTable();
            System.Web.UI.HtmlControls.HtmlTableRow Hrow = new HtmlTableRow();
            System.Web.UI.HtmlControls.HtmlTableCell cell01 = new HtmlTableCell();  //I want to try to concatenate
            //use a literal to build the statement, then assign a differents literal the text  alue of the statement string.
            System.Web.UI.HtmlControls.HtmlTableCell cell02 = new HtmlTableCell();
            System.Web.UI.HtmlControls.HtmlTableCell cell03 = new HtmlTableCell();

             Label Label1 = new Label();
            Label1.Text = "1";
            Label Label2 = new Label();
            Label2.Text = "Tom Jenkins";
            Label Label3 = new Label();
            Label3.Text = "[email protected]";

            Literal lit1 = new Literal();
            Literal lit2 = new Literal();
            Literal lit3 = new Literal();

            lit1.Text = "Literal 1";
            lit2.Text = "Literal 2";
            lit3.Text = "Literal 3";

            Htable.Border = 1;
            cell01.InnerHtml = "ID";
            cell02.InnerHtml = "Name";
            cell03.InnerHtml = "email";

            Hrow.Cells.Add(cell01);
            Hrow.Cells.Add(cell02);
            Hrow.Cells.Add(cell03);
            Htable.Rows.Add(Hrow);

            cell01 = new HtmlTableCell();
            cell02 = new HtmlTableCell();
            cell03 = new HtmlTableCell();

            cell01.InnerHtml = lit1.ToString();
            cell02.InnerHtml = lit2.ToString();
            cell03.InnerHtml = lit3.ToString();
            Hrow = new HtmlTableRow();
            Hrow.Cells.Add(cell01);
            Hrow.Cells.Add(cell02);
            Hrow.Cells.Add(cell03);

            Htable.Rows.Add(Hrow);
            this.Controls.Add(Htable);

              //do while (i < 3)
              //  {

              //    i++;
              //  }

            //string[] arr = new string[4]; // Initialize
            //arr[0] = "one";               // Element 1
            //arr[1] = "two";               // Element 2
            //arr[2] = "three";             // Element 3
            //arr[3] = "four";              // Element 4

            //// Loop over strings
            //foreach (string s in arr)
            //{
            //    Console.WriteLine(s);
            //}

               //// Array a1 = new Array[1, 2, 3, 4];
               // string[] a1 = new string[2];
               // a1[0] = "First Element";
               // a1[1] = "Second Element";
               // a1[2] = "Third Element";
               // foreach (string s in a1)
               // {
               //     Label lba = new Label();
               //     lba.Text = a1[i].ToString();

               //     Console.WriteLine(s);
               // }

            // for i = o while i is less than row count plus or minus 1, loop through and array and do something to practice looping data with arrays, collections, and tables.
            //A tables, b for each loops with different types of data, and C using an array to work on this and add data. Use these controls in an array.
            //DynamicControlsPlaceholder (DCP)

                //look into web controls, what they cand be used for, and how they differ from HTML table contr
        }
开发者ID:Treasureman1,项目名称:PersonManager,代码行数:88,代码来源:WebForm3.aspx.cs


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