| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 
 |  
    public static void LoadControl(System.Web.UI.Control HostControl, string VirtualFileName)
    {
        string FileContent = System.IO.File.ReadAllText(MapPath(HostControl,VirtualFileName), System.Text.Encoding.UTF7);
        System.Text.RegularExpressions.Regex rega = new System.Text.RegularExpressions.Regex(@"[#]ROOT[/]", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline);
        FileContent = rega.Replace(FileContent, RootPath(HostControl));
        if (HostControl.Site!=null)
        {
            System.ComponentModel.Design.IDesignerHost host = (System.ComponentModel.Design.IDesignerHost)(HostControl.Site.GetService(typeof(System.ComponentModel.Design.IDesignerHost)));
            Control[] ctrls = System.Web.UI.Design.ControlParser.ParseControls(host, FileContent);
            int pos = HostControl.Controls.Count;
            for (int i = ctrls.Length - 1; i >= 0; i--)
            {
                HostControl.Controls.AddAt(pos, ctrls[i]);
            }
        }
        else
        {
            Control ctrl = HostControl.Page.ParseControl(FileContent);
            int pos = HostControl.Controls.Count;
            for (int i = ctrl.Controls.Count - 1; i >= 0; i--)
            {
                HostControl.Controls.AddAt(pos, ctrl.Controls[i]);
            }
        }
    } | 
Partager