zoukankan      html  css  js  c++  java
  • PlaceHolder控件的使用

    一、简介

      PlaceHolder为asp.net服务器控件用于为代码添加的控件预留空间,下面将介绍下其实际的应用场景。  

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

    二、实际应用场景

    1、动态添加js

    cs文件:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    using System.Text;
    
    namespace UI
    {
        public partial class Test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {            
                Literal Li = new Literal();
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("<script src="Scripts/Test.js"></script>");
                Li.Text = sb.ToString();           
                PH.Controls.Add(Li);           
    
            }
        }
    }

    Html文件:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="UI.Test" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>    
        <asp:PlaceHolder ID="PH" runat="server"></asp:PlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            
        </div>
        </form>
    </body>
    </html>

    效果图:

    说明:

  • 相关阅读:
    PowerMock详解
    java -agent与Javassist
    gradle_____最后到齐的构建工具
    JVM--参数调优
    提高速度 history 的利用
    shell-异步执行
    redis常用命令与使用分析
    chrome mac 快捷键
    idea的快捷键和操作
    mysql事务以及隔离级别
  • 原文地址:https://www.cnblogs.com/YanYongSong/p/5375060.html
Copyright © 2011-2022 走看看