LayoutFarm.WebDom.DomElement.SetAttribute C# (CSharp) Method

SetAttribute() public method

public SetAttribute ( DomAttribute attr ) : void
attr DomAttribute
return void
        public virtual void SetAttribute(DomAttribute attr)
        {
            if (myAttributes == null)
            {
                myAttributes = new Dictionary<int, DomAttribute>();
            }
            //-----------
            //some wellknownattr 
            switch ((WellknownName)attr.LocalNameIndex)
            {
                case WellknownName.Id:
                    {
                        this.attrElemId = attr;
                        this.OwnerDocument.RegisterElementById(this);
                    }
                    break;
                case WellknownName.Class:
                    {
                        this.attrClass = attr;
                    }
                    break;
            }
            //--------------------
            var attrNameIndex = this.OwnerDocument.AddStringIfNotExists(attr.LocalName);
            myAttributes[attrNameIndex] = attr;//update or replace 
            attr.SetParent(this);
            NotifyChange(ElementChangeKind.AddAttribute);
            //---------------------
        }
        public void SetAttribute(string attrName, string value)

Same methods

DomElement::SetAttribute ( string attrName, string value ) : void

Usage Example

示例#1
0
        public DomElement GetTitleNode(DomElement hostNode)
        {
            //-------------------------------------
            if (titleNode != null) return titleNode;
            //create dom node
            var ownerdoc = hostNode.OwnerDocument;
            this.titleNode = ownerdoc.CreateElement("div");
            titleNode.SetAttribute("style", "display:inline");
            titleNode.AddChild("span", span =>
            {
                if (PageTitle == null)
                {
                    span.AddTextContent("");
                }
                else
                {
                    span.AddTextContent(this.PageTitle);
                }
                span.AttachMouseDownEvent(e =>
                {
                    if (this.OwnerContainer != null)
                    {
                        this.OwnerContainer.ChildNotifyTabMouseDown(this);
                    }
                });
            });
            ////mouse down on title
            //titleNode.AttachMouseDownEvent(e =>
            //{


            //});
            //-------------------------------------
            return titleNode;
        }
All Usage Examples Of LayoutFarm.WebDom.DomElement::SetAttribute