前台:

<body>
    <form id="form1" runat="server">
        <%--网页的循环--%>
        <%for(int i = 0;i<f.Length;i++) 
          {%>
    <div>
        <%=f[i]%>
    </div>
        <% }%>
        <div id="aa" runat="server"></div>
        <%=cc %><%--定义变量--%>
    </form>
</body>

后台:

public partial class _Default : System.Web.UI.Page
{
    public string[] f = new string[] { "1", "3", "4", "5" };//前台的循环赋值
    public string cc = "111111111";//变量的定义和赋值
    protected void Page_Load(object sender, EventArgs e)
    {
        aa.InnerHtml = "11111";//对前台id为"aa"的控件赋值
        
    }
}

 

posted on 2017-10-14 17:40  金琥  阅读(246)  评论(0编辑  收藏  举报