helpcenter/Web/App_Code/LocalizeContent.cs

48 lines
1.2 KiB
C#
Raw Permalink Normal View History

2016-08-29 13:51:20 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
namespace TeamLab.Controls
{
[ParseChildren(false), PersistChildren(false)]
public class LocalizeContent : TemplateControl
{
private BasePage basePage;
public string ControlName { get; set; }
Control ctrl = null;
protected override void OnLoad(EventArgs e)
{
if (ctrl is BaseContentUserControls)
{
(ctrl as BaseContentUserControls).UpdatePage();
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
basePage = Page as BasePage;
if (string.IsNullOrEmpty(ControlName))
{
return;
}
string controlFileName = basePage.GetContentFileName(ControlName);
if(!string.IsNullOrEmpty(controlFileName))
{
Controls.Clear();
ctrl = this.LoadControl(controlFileName);
Controls.Add(ctrl);
}
}
}
}