本文整理汇总了C#中System.Web.UI.ControlCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ControlCollection.Remove方法的具体用法?C# ControlCollection.Remove怎么用?C# ControlCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.ControlCollection
的用法示例。
在下文中一共展示了ControlCollection.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deny_Unrestricted
public void Deny_Unrestricted ()
{
// note: using the same control (as owner) to add results
// in killing the ms runtime with a stackoverflow - FDBK36722
ControlCollection cc = new ControlCollection (new Control ());
Assert.AreEqual (0, cc.Count, "Count");
Assert.IsFalse (cc.IsReadOnly, "IsReadOnly");
Assert.IsFalse (cc.IsSynchronized, "IsSynchronized");
Assert.IsNotNull (cc.SyncRoot, "SyncRoot");
cc.Add (control);
Assert.IsNotNull (cc[0], "this[int]");
cc.Clear ();
cc.AddAt (0, control);
Assert.IsTrue (cc.Contains (control), "Contains");
cc.CopyTo (new Control[1], 0);
Assert.IsNotNull (cc.GetEnumerator (), "GetEnumerator");
Assert.AreEqual (0, cc.IndexOf (control), "IndexOf");
cc.RemoveAt (0);
cc.Remove (control);
}
示例2: RemoveProblemTypes
static public void RemoveProblemTypes(ControlCollection coll, List<ControlRestorationInfo> stashedControls)
{
foreach (Control ctrl in coll)
{
if (typeof(RequiredFieldValidator).IsAssignableFrom(ctrl.GetType()) ||
typeof(CompareValidator).IsAssignableFrom(ctrl.GetType()) ||
typeof(RegularExpressionValidator).IsAssignableFrom(ctrl.GetType()) ||
typeof(ValidationSummary).IsAssignableFrom(ctrl.GetType()))
{
ControlRestorationInfo cri = new ControlRestorationInfo(ctrl, coll);
stashedControls.Add(cri);
coll.Remove(ctrl);
continue;
}
if (ctrl.HasControls())
{
RemoveProblemTypes(ctrl.Controls, stashedControls);
}
}
}
示例3: HandleControls
/// <summary>
/// Moves all templated controls of a given region provider
/// into their target regions.
/// </summary>
/// <param name="template">The template to be used.</param>
/// <param name="controls">Controls to move into the template.</param>
/// <param name="provider">Provides region assignements for the controls.</param>
/// <param name="page">The currently rendered page.</param>
protected static void HandleControls(IPortalTemplate template, RegionProvider provider, ControlCollection controls, Page page)
{
//force template control creation now by adding / removing the template
Control templateControl = (Control)template;
controls.Add(templateControl);
controls.Remove(templateControl);
//call initialization code of the template
template.BeforeTemplating(page);
//add defined controls to their target region
RegionPlaceHolder placeHolder;
foreach (RegionPropertySet propertySet in provider)
{
placeHolder = template[propertySet.TargetRegion];
if (placeHolder == null)
{
string msg = "Invalid region defined for control {0}. Template does not contain region '{1}'";
msg = String.Format(msg, propertySet.Control.ID, propertySet.TargetRegion);
throw new ArgumentException(msg);
}
//remove templated control from original location...
controls.Remove(propertySet.Control);
//...and put it into placeholder
placeHolder.Controls.Add(propertySet.Control);
}
//add remaining controls to default region, if any
if (provider.DefaultRegion != PortalRegion.None)
{
placeHolder = template[provider.DefaultRegion];
if (placeHolder == null)
{
string msg = "Invalid default region defined: Template does not contain region '{0}'";
msg = String.Format(msg, provider.DefaultRegion);
throw new ArgumentException(msg);
}
//move remaining controls into the template's controls
ControlUtil.MoveControls(controls, placeHolder.Controls);
}
//Everything is now in the template. Now move all the template's
//controls back into the page's control collection. This is necessary
//to keep relative links of the web form working
ControlUtil.MoveControls(templateControl.Controls, controls);
//call initialization code of the template
template.AfterTemplating(page);
}