zoukankan      html  css  js  c++  java
  • 在ascx中调用另一个ascx的写法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    
    namespace Ascxcontrol.Controls
    {
    public partial class controlone : System.Web.UI.UserControl
    {
    //Literal1.Text = RenderUserControlToString("../Controls/controltwo.ascx");
    private string RenderUserControlToString(string ucpath)
    {
    UserControl uc = (UserControl)this.LoadControl(ucpath);
    using (TextWriter tw = new StringWriter())
    using (HtmlTextWriter htw=new HtmlTextWriter(tw))
    {
    uc.RenderControl(htw);
    return tw.ToString();
    }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    for (int i = 0; i < 10; i++)
    {
    controltwo ct = (controltwo)this.LoadControl("../Controls/controltwo.ascx");
    ct.Text = i.ToString();
    PlaceHolder1.Controls.Add(ct);
    }
    }
    }
    }

      感谢:csdn   insus

  • 相关阅读:
    关于codeblocks插件(持续更新)
    自定义gvim配色方案qiucz.vim的源码
    mark it
    poj 1032
    poj 1028
    最小公倍数是lcm
    problems
    hdu 1067
    某些题的做法。。。
    突然明白了什么
  • 原文地址:https://www.cnblogs.com/anbylau2130/p/3147925.html
Copyright © 2011-2022 走看看