/// <summary> /// Detach the behavior from the HTML element /// </summary> public void DetachFromElement() { if (!_manuallyAttached) { throw new InvalidOperationException("Attempted to detach behavior from element where behavior was not manually attached."); } // remove behavior (will result in call to IElementBehaviorRaw.Detach) if (_htmlElement != null) { IHTMLElement2 element2 = (IHTMLElement2)_htmlElement; element2.removeBehavior(_behaviorCookie); } }