本文整理汇总了C#中System.Web.UI.UserControl.LoadControl方法的典型用法代码示例。如果您正苦于以下问题:C# UserControl.LoadControl方法的具体用法?C# UserControl.LoadControl怎么用?C# UserControl.LoadControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.UserControl
的用法示例。
在下文中一共展示了UserControl.LoadControl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadControlFromVirtualPath
/// <summary>
/// Load a webforms view (Page, UserControl, MasterPage) from the given virtual path.
/// </summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
public static Control LoadControlFromVirtualPath(string virtualPath)
{
// We're using LoadControl of an arbitrary UserControl to load the view. We could also use the BuildManager, but
// in that case, the control hierarchy appears to be empty and thus, pretty useless.
UserControl controlLoader = new UserControl();
return controlLoader.LoadControl(virtualPath);
}
示例2: OnInit
bool UserControl { get { return !string.IsNullOrEmpty(Path); } } // we must load a UserControl
protected override void OnInit(EventArgs e) {
try {
if (UserControl) {
var userControl = new UserControl();
LoadedControl = userControl.LoadControl(Path);
}
} catch { }
base.OnInit(e);
}
示例3: AddComponent
/// <summary>
/// Adds the component to dealer product group.
/// </summary>
/// <param name="componentPath">The component path.</param>
/// <param name="targetControlName">Name of the target control.</param>
/*private void AddComponentToDealerProductGroup(string componentPath, string targetControlName)
{
if (!string.Equals(Sitecore.Context.GetSiteName(), "dealer") || !Sitecore.Context.Item.IsItemOfType(Consts.ProducGroupTemplateId))
{
return;
}
this.AddComponent(componentPath, targetControlName);
}*/
/// <summary>
/// Adds the component cart to product on dealer site.
/// </summary>
/// <param name="componentPath">The component path.</param>
/// <param name="targetControlName">Name of the target control.</param>
/*private void AddComponentToDealerProduct(string componentPath, string targetControlName)
{
if (!string.Equals(Sitecore.Context.GetSiteName(), "dealer") || !Sitecore.Context.Item.IsItemOfType(Consts.ProducBaseTemplateId))
{
return;
}
this.AddComponent(componentPath, targetControlName);
}*/
/// <summary>
/// Adds the component.
/// </summary>
/// <param name="componentPath">The component path.</param>
/// <param name="targetControlName">Name of the target control.</param>
private void AddComponent(string componentPath, string targetControlName)
{
var rightColumn = this.GetControl(this.Page, targetControlName);
if (rightColumn == null)
{
return;
}
var temp = new UserControl();
var ctrl = temp.LoadControl(componentPath);
Assert.IsNotNull(ctrl, string.Format("Failed to load control '{0}'", componentPath));
rightColumn.Controls.AddAt(0, ctrl);
}