/// <summary> /// Attach the behavior to an HTML element /// </summary> /// <param name="element">element to attach to</param> public void AttachToElement(IHTMLElement element) { if (_htmlElement != null) throw new InvalidOperationException("Attempted to attach element to already initialized behavior"); // attach this object to the element as a rendering behavior _htmlElement = element; IHTMLElement2 elementTarget = (IHTMLElement2)_htmlElement; object itemRenderingBehaviorFactory = new ElementBehaviorFactoryForExistingBehavior(this); _behaviorCookie = elementTarget.addBehavior(null, ref itemRenderingBehaviorFactory); // note that we are manually attached _manuallyAttached = true; }
/// <summary> /// Attach the behavior to an HTML element /// </summary> /// <param name="element">element to attach to</param> public void AttachToElement(IHTMLElement element) { if (_htmlElement != null) { throw new InvalidOperationException("Attempted to attach element to already initialized behavior"); } // attach this object to the element as a rendering behavior _htmlElement = element; IHTMLElement2 elementTarget = (IHTMLElement2)_htmlElement; object itemRenderingBehaviorFactory = new ElementBehaviorFactoryForExistingBehavior(this); _behaviorCookie = elementTarget.addBehavior(null, ref itemRenderingBehaviorFactory); // note that we are manually attached _manuallyAttached = true; }