• web服务器控件PlaceHolder应用


    placeHolder在html页面中,并没有什么标记显示.它最大的作用就是能向其动态的添加控件.其中如果想向其添加Html标记,则要用LiteralControl来实现,

    <body>

        <form id="form1" runat="server">

          <asp:PlaceHolder ID="PlaceHolder1" runat ="server" />

          <asp:Button ID="button1" runat ="server" OnClick="button1_Click" Text ="ControlAdd" />

          <asp:Label ID="lbMsg" runat ="server" />

        </form>

    </body>

     

    protected void button1_Click(object sender, EventArgs e)

        {

            try

            {

                for (int i = 0; i < 3; i++)

                {

                    Image img = new Image();

                    img.ImageUrl = @"images/"+i.ToString()+".bmp";

                    LiteralControl br = new LiteralControl("<br>");

                    PlaceHolder1.Controls.Add(img);

                    PlaceHolder1.Controls.Add(br);

                }

                lbMsg.Text = "添加成功!";

            }

            catch(Exception ex)

            {

                lbMsg.Text = ex.Message;

            }

        }

  • 相关阅读:
    事件冒泡
    Tomcat 不能正常启动
    mybatis(非常详细的哦~~~~)
    javadoc 工具生成开发API文档
    Java 泛型
    Tomcat 服务器详解
    J2EE 工作中注意事项
    Java 枚举
    Break,Continue,Return
    位运算符
  • 原文地址:https://www.cnblogs.com/wenming205/p/1286223.html
Copyright © 2020-2023  润新知