/// <include file='doc\UserControlDesigner.uex' path='docs/doc[@for="ControlDesigner.RemoveSizeAttributes"]/*' /> /// <devdoc> /// <para> /// Maps the width, height, left and top style attributes to the respective properties /// on the web control. /// </para> /// </devdoc> private void RemoveSizeAttributes() { Debug.Assert(IsWebControl, "RemoveSizeAttributes should only be called for WebControls"); NativeMethods.IHTMLElement htmlElement = (NativeMethods.IHTMLElement)DesignTimeElement; if (htmlElement == null) { return; } NativeMethods.IHTMLStyle htmlStyle = htmlElement.GetStyle(); if (htmlStyle == null) { return; } try { string cssText = htmlStyle.GetCssText(); if (cssText == null || cssText.Equals(String.Empty)) { return; } WebControl control = (WebControl)Component; // Obtain the left, top and position style attributes from Trident. int width = htmlStyle.GetPixelWidth(); int height = htmlStyle.GetPixelHeight(); if (width > 0) { control.Width = width; htmlElement.SetAttribute("Width", width, 0); } if (height > 0) { control.Height = height; htmlElement.SetAttribute("Height", height, 0); } } catch (Exception ex) { Debug.Fail(ex.ToString()); } // Remove the width and height style attributes. htmlStyle.RemoveAttribute("width", /*lFlags*/ 0); htmlStyle.RemoveAttribute("height", /*lFlags*/ 0); }
/// <summary>Toggle the design time lock state of the selected items.</summary> public void ToggleLock() { //Switch the lock on each item foreach (NativeMethods.IHTMLElement element in this.items) { NativeMethods.IHTMLStyle style = element.GetStyle(); if (IsElementLocked(element)) { // We need to remove attributes off the element and the style because of a bug in Trident element.RemoveAttribute(DesignTimeLockAttribute, 0); style.RemoveAttribute(DesignTimeLockAttribute, 0); } else { //We need to add attributes to the element and the style because of a bug in Trident element.SetAttribute(DesignTimeLockAttribute, "true", 0); style.SetAttribute(DesignTimeLockAttribute, "true", 0); } } }