Ejemplo n.º 1
0
 public static void AddImageLinkAttribute(HtmlTextWriter writer, HtmlTextWriterAttribute attribute, string imageID)
 {
     if (imageID != String.Empty)
     {
         writer.AddAttribute(attribute, "ViewImage.aspx?ImageID=" + imageID, false);
     }
 }
Ejemplo n.º 2
0
 public void AddAttributeIfUndefined(HtmlTextWriterAttribute attribute, string value)
 {
     if (!IsAttributeDefined(attribute))
     {
         AddAttribute(attribute, value);
     }
 }
 public static void AddAttributeIfHave(this HtmlTextWriter writer, HtmlTextWriterAttribute key, string value)
 {
     if (!string.IsNullOrEmpty(value))
     {
         writer.AddAttribute(key, value);
     }
 }
Ejemplo n.º 4
0
 protected virtual void AddAttribute(string name, string value, HtmlTextWriterAttribute key)
 {
     NextAttrStack();
     attrs [attrs_pos].name  = name;
     attrs [attrs_pos].value = value;
     attrs [attrs_pos].key   = key;
 }
Ejemplo n.º 5
0
 protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
 {
     // FIXME:
     // I checked every possible HtmlTextWriterAttribute key
     // and always throws ArgumentNullException.
     return((bool)attr_render [null]);
 }
Ejemplo n.º 6
0
        public void EnsureEnumerations()
        {
            WriteDictionaryEntries <HtmlTextWriterTag>();
            WriteDictionaryEntries <HtmlTextWriterAttribute>();

            using MemoryStream mem      = new MemoryStream();
            using StreamWriter sw       = new StreamWriter(mem);
            using HtmlTextWriter writer = new HtmlTextWriter(sw);

            foreach (FieldInfo tagInfo in typeof(HtmlTextWriterTag).GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                HtmlTextWriterTag tag = (HtmlTextWriterTag)tagInfo.GetRawConstantValue();
                if (tag == HtmlTextWriterTag.Unknown)
                {
                    continue;
                }

                writer.RenderBeginTag(tag);

                foreach (FieldInfo attrInfo in typeof(HtmlTextWriterAttribute).GetFields(BindingFlags.Public | BindingFlags.Static))
                {
                    HtmlTextWriterAttribute attr = (HtmlTextWriterAttribute)attrInfo.GetRawConstantValue();
                    writer.AddAttribute(attr, "1");
                }

                writer.RenderEndTag();
            }
Ejemplo n.º 7
0
        public virtual void AddAttribute(string name, string value)
        {
            HtmlTextWriterAttribute attributeKey = GetAttributeKey(name);

            value = EncodeAttributeValue(attributeKey, value);

            AddAttribute(name, value, attributeKey);
        }
 public PendingAttribute (string name, string value, HtmlTextWriterAttribute a, bool encode, bool know_encode)
 {
     this.name = name;
     this.value = value;
     this.a = a;
     this.encode = encode;
     this.know_encode = know_encode;
 }
Ejemplo n.º 9
0
		protected override void AddAttribute (string name, string value, HtmlTextWriterAttribute key)
		{
			output.WriteLine ("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex (), name, value, key);
			if (full_trace)
				WriteTrace (new StackTrace ());

			base.AddAttribute (name, value, key);
		}
Ejemplo n.º 10
0
		public PendingAttribute (string name, string value, HtmlTextWriterAttribute a, bool encode, bool know_encode)
		{
			this.name = name;
			this.value = value;
			this.a = a;
			this.encode = encode;
			this.know_encode = know_encode;
		}
Ejemplo n.º 11
0
 /// <summary>
 /// Applies specified attribute (with no value) to the HtmlTextWriter
 /// this instance contains.
 /// </summary>
 /// <param name="attribute">The attribute to set.</param>
 /// <returns>The attribute manager.</returns>
 public HtmlAttributeManager this[HtmlTextWriterAttribute attribute]
 {
     get
     {
         this.Writer.AddAttribute(attribute, null);
         return(this);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Applies the value to the specified attribute to the HtmlTextWriter
 /// this instance contains.
 /// </summary>
 /// <param name="attribute">The attribute to set.</param>
 /// <param name="value">The value to set to the attribute.</param>
 /// <returns>The attribute manager.</returns>
 public HtmlAttributeManager this[HtmlTextWriterAttribute attribute, string value]
 {
     get
     {
         this.Writer.AddAttribute(attribute, value);
         return(this);
     }
 }
Ejemplo n.º 13
0
		public override void AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode)
		{
			output.WriteLine ("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex (), key, value, fEncode);
			if (full_trace)
				WriteTrace (new StackTrace ());

			base.AddAttribute (key, value, fEncode);
		}
Ejemplo n.º 14
0
        protected string GetAttributeName(HtmlTextWriterAttribute attrKey)
        {
            if ((int)attrKey >= 0 && (int)attrKey < _attrNameLookupArray.Length)
            {
                return(_attrNameLookupArray [(int)attrKey].name);
            }

            return(string.Empty);
        }
Ejemplo n.º 15
0
 public bool TryAddAttribute(HtmlTextWriterAttribute key, out string value)
 {
     if (!IsAttributeDefined(key, out value))
     {
         AddAttribute(key, value);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 16
0
        private void AddDimensionToAttributes(HtmlTextWriter writer, HtmlTextWriterAttribute attribute, Unit attributeValue)
        {
            if (attributeValue.IsEmpty)
            {
                return;
            }

            writer.AddStyleAttribute(GetDimensionAsStyleAttribute(attribute), attributeValue.ToString());
        }
Ejemplo n.º 17
0
        public virtual void AddAttribute(HtmlTextWriterAttribute key, string value)
        {
            if ((key != HtmlTextWriterAttribute.Name) && (key != HtmlTextWriterAttribute.Id))
            {
                value = HttpUtility.HtmlAttributeEncode(value);
            }

            AddAttribute(GetAttributeName(key), value, key);
        }
Ejemplo n.º 18
0
        public override void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode)
        {
            if (key == HtmlTextWriterAttribute.Src)
            {
                value = _imageUrl;
            }

            base.AddAttribute(key, value, fEncode);
        }
Ejemplo n.º 19
0
        protected string GetAttributeName(HtmlTextWriterAttribute attrKey)
        {
            if ((int)attrKey < htmlattrs.Length)
            {
                return(htmlattrs [(int)attrKey].name);
            }

            return(null);
        }
Ejemplo n.º 20
0
        private String GetAttributeName(HtmlTextWriterAttribute key)
        {
            String name = key.ToString().ToLower();

            if (name.Contains("."))
            {
                name = name.Substring(name.LastIndexOf(".") + 1);
            }
            return(name);
        }
Ejemplo n.º 21
0
        /// <devdoc>
        /// <para>[To be supplied.]</para>
        /// </devdoc>
        protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
        {
            if (_commonAttributes[name] != null && _suppressCommonAttributes[TagName] == null)
            {
                return(true);
            }

            // TagName is valid when OnAttributeRender is called.
            return(_elementSpecificAttributes[TagName] != null && ((Hashtable)_elementSpecificAttributes[TagName])[name] != null);
        }
 public HtmlTagBuilder MergeAttribute(HtmlTextWriterAttribute attribute, object value,
                                      bool replaceExisting = false)
 {
     Enforce.Argument(() => value);
     if (replaceExisting || !Attributes.ContainsKey(attribute))
     {
         Attributes[attribute] = value;
     }
     return(this);
 }
        protected override void AddAttribute(string name, string value, HtmlTextWriterAttribute key)
        {
            output.WriteLine("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex(), name, value, key);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            base.AddAttribute(name, value, key);
        }
        public override void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode)
        {
            output.WriteLine("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex(), key, value, fEncode);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            base.AddAttribute(key, value, fEncode);
        }
        protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
        {
            output.WriteLine("{0:###0} OnAttributeRender ({1}, {2}, {3})", NextIndex(), name, value, key);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            return(base.OnAttributeRender(name, value, key));
        }
        protected override string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value)
        {
            output.WriteLine("{0:###0} EncodeAttributeValue ({1}, {2})", NextIndex(), attrKey, value);
            if (full_trace)
            {
                WriteTrace(new StackTrace());
            }

            return(base.EncodeAttributeValue(attrKey, value));
        }
Ejemplo n.º 27
0
        public virtual void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode)
        {
            int attributeIndex = (int)key;

            if (attributeIndex >= 0 && attributeIndex < _attrNameLookupArray.Length)
            {
                AttributeInformation info = _attrNameLookupArray [attributeIndex];
                AddAttribute(info.name, value, key, fEncode, info.isUrl);
            }
        }
    protected override void AddAttribute (string name, string value, HtmlTextWriterAttribute key)
    {
        if (filtering)
        {
            base.AddAttribute (name, value, key);
            return;
        }

        pending_attrs.Add (new PendingAttribute (name, value, key, false, false));
    }
    //
    // Some idiot at microsoft did not do a sanity check on this api,
    // thus forcing me to deal with some serious pain.
    //
    public override void AddAttribute (HtmlTextWriterAttribute key, string value)
    {
        if (filtering)
        {
            base.AddAttribute (key, value);
            return;
        }

        pending_attrs.Add (new PendingAttribute (GetAttributeName (key), value, key, false, false));
    }
 public override void AddAttribute(HtmlTextWriterAttribute key, string value)
 {
     if (((key == HtmlTextWriterAttribute.Src) || (key == HtmlTextWriterAttribute.Href)) || (key == HtmlTextWriterAttribute.Background))
     {
         base.AddAttribute(key.ToString(), value, key);
     }
     else
     {
         base.AddAttribute(key, value);
     }
 }
Ejemplo n.º 31
0
 protected bool IsAttributeDefined(HtmlTextWriterAttribute key)
 {
     for (int i = 0; i < _attrCount; i++)
     {
         if (_attrList [i].key == key)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 32
0
        public virtual void AddAttribute(string name, string value)
        {
            HtmlTextWriterAttribute key = GetAttributeKey(name);

            if ((key != HtmlTextWriterAttribute.Name) && (key != HtmlTextWriterAttribute.Id))
            {
                value = HttpUtility.HtmlAttributeEncode(value);
            }

            AddAttribute(name, value, key);
        }
Ejemplo n.º 33
0
        private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool encode, bool isUrl)
        {
            string nameLCase = name;            //.ToLower ();

            _attrKeyLookupTable.Add(nameLCase, key);

            if ((int)key < _attrNameLookupArray.Length)
            {
                _attrNameLookupArray [(int)key] = new AttributeInformation(name, encode, isUrl);
            }
        }
Ejemplo n.º 34
0
        protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value)
        {
            bool encode = true;

            if (0 <= (int)attrKey && (int)attrKey < _attrNameLookupArray.Length)
            {
                encode = _attrNameLookupArray [(int)attrKey].encode;
            }

            return(EncodeAttributeValue(value, encode));
        }
        public override void AddAttribute(HtmlTextWriterAttribute key, string value)
        {
            if (_allowedMultiValueAttrs.Contains(key))
            {
                if (!_attrValues.ContainsKey(key))
                    _attrValues.Add(key, new List<string>());

                _attrValues[key].Add(value);
            }
            else
            {
                base.AddAttribute(key, value);
            }
        }
Ejemplo n.º 36
0
        public override void AddAttribute(HtmlTextWriterAttribute key, string value)
        {
            if (multiValueAttrs != null && multiValueAttrs.Contains(key))
            {
                if (!attrValues.ContainsKey(key))
                    attrValues.Add(key, new List<string>());

                attrValues[key].Add(value);
            }
            else
            {
                base.AddAttribute(key, value);
            }
        }
 protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
 {
     Hashtable hashtable = (Hashtable) this._recognizedAttributes[base.TagName];
     if ((hashtable == null) || (hashtable[name] == null))
     {
         if (this._globalSuppressedAttributes[name] != null)
         {
             return false;
         }
         Hashtable hashtable2 = (Hashtable) this._suppressedAttributes[base.TagName];
         if ((hashtable2 != null) && (hashtable2[name] != null))
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 38
0
        /// <devdoc>
        /// Override to filter out unnecessary attributes
        /// </devdoc>
        protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key) {
            Hashtable elementRecognizedAttributes = (Hashtable)_recognizedAttributes[TagName];
            if (elementRecognizedAttributes != null && elementRecognizedAttributes[name] != null) {
                return true;
            }
            
            if (_globalSuppressedAttributes[name] != null) {
                return false;
            }
            
            Hashtable elementSuppressedAttributes = (Hashtable)_suppressedAttributes[TagName];
            if (elementSuppressedAttributes != null && elementSuppressedAttributes[name] != null) {
                return false;
            }

            return true;
        }
Ejemplo n.º 39
0
 public override void AddAttribute(HtmlTextWriterAttribute key, String value)
 {
     if (HasRenderedFirstTag) {
         base.AddAttribute(key, value);
     } else if (key == HtmlTextWriterAttribute.Type) {
         // Ignore.
     } else if (key == HtmlTextWriterAttribute.Value) {
         // Ignore.
     } else {
         base.AddAttribute(key, value);
     }
 }
Ejemplo n.º 40
0
            /// <summary>
            /// ・POSTデータから値を読み込んでコントロールの状態を復元します。
            /// ・また、コントロールの状態が変わったらtrueを返します。
            /// </summary>
            /// <param name="key">Attributeのkey</param>
            /// <param name="value">Attributeのvalue</param>
            public override void AddAttribute(HtmlTextWriterAttribute key, string value)
            {
                // 描画時にname属性にGroupNameを、value属性にUniqueIDを設定
                switch (key)
                {
                    case HtmlTextWriterAttribute.Name:
                        base.AddAttribute(key, this._ctrl.GroupName);
                        break;

                    case HtmlTextWriterAttribute.Value:
                        base.AddAttribute(key, this._ctrl.UniqueID);
                        break;

                    default:
                        base.AddAttribute(key, value);
                        break;
                }
            }
Ejemplo n.º 41
0
 public override void AddAttribute(HtmlTextWriterAttribute key, String value)
 {
     if (HasRenderedFirstTag) {
         base.AddAttribute(key, value);
     } else if (key == HtmlTextWriterAttribute.Onclick) {
         value +=
             ";(function(e){" +
               "setTimeout(function(){" +
                 "e.disabled=(window.Page_IsValid !== true) ? false : (e.form && e.form.checkValidity && e.form.checkValidity());" +
               "}, 0);" +
             "})(this);";
         base.AddAttribute(key, value);
     } else {
         base.AddAttribute(key, value);
     }
 }
 public virtual void AddAttribute(HtmlTextWriterAttribute key,string value, bool fEncode) {
     int attributeIndex = (int) key;
     if (attributeIndex >= 0 &&  attributeIndex < _attrNameLookupArray.Length) {
         AttributeInformation info = _attrNameLookupArray[attributeIndex];
         AddAttribute(info.name,value,key, fEncode, info.isUrl);
     }
 }
 protected string GetAttributeName(HtmlTextWriterAttribute attrKey)
 {
     if ((attrKey >= HtmlTextWriterAttribute.Accesskey) && (attrKey < _attrNameLookupArray.Length))
     {
         return _attrNameLookupArray[(int) attrKey].name;
     }
     return string.Empty;
 }
        private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool encode, bool isUrl) {
            string nameLCase = name.ToLower(CultureInfo.InvariantCulture);

            _attrKeyLookupTable.Add(nameLCase, key);

            if ((int)key < _attrNameLookupArray.Length) {
                _attrNameLookupArray[(int)key] = new AttributeInformation(name, encode, isUrl);
            }
        }
 protected static void RegisterAttribute(string name, HtmlTextWriterAttribute key) {
     RegisterAttribute(name, key, false);
 }
 /// <summary>
 /// Applies the value to the specified attribute to the HtmlTextWriter
 /// this instance contains.
 /// </summary>
 /// <param name="key">The attribute to set.</param>
 /// <param name="value">The value to set to the attribute.</param>
 /// <returns>The attribute manager.</returns>
 public HtmlAttributeManager Attr(HtmlTextWriterAttribute key, string value)
 {
     Writer.AddAttribute(key, value);
     return this;
 }
	public virtual void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode) {}
 protected bool IsAttributeDefined(HtmlTextWriterAttribute key) {
     for (int i = 0; i < _attrCount; i++) {
         if (_attrList[i].key == key) {
             return true;
         }
     }
     return false;
 }
        protected string GetAttributeName(HtmlTextWriterAttribute attrKey) {
            if ((int)attrKey >= 0 && (int)attrKey < _attrNameLookupArray.Length)
                return _attrNameLookupArray[(int)attrKey].name;

            return string.Empty;
        }
        protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value) {
            bool encode = true;

            if (0 <= (int)attrKey && (int)attrKey < _attrNameLookupArray.Length) {
                encode = _attrNameLookupArray[(int)attrKey].encode;
            }

            return EncodeAttributeValue(value, encode);
        }
 private void AddAttribute(string name, string value, HtmlTextWriterAttribute key, bool encode, bool isUrl) {
     if(_attrList == null) {
         _attrList = new RenderAttribute[20];
     }
     else if (_attrCount >= _attrList.Length) {
         RenderAttribute[] newArray = new RenderAttribute[_attrList.Length * 2];
         Array.Copy(_attrList, newArray, _attrList.Length);
         _attrList = newArray;
     }
     RenderAttribute attr;
     attr.name = name;
     attr.value = value;
     attr.key = key;
     attr.encode = encode;
     attr.isUrl = isUrl;
     _attrList[_attrCount] = attr;
     _attrCount++;
 }
 protected virtual void AddAttribute(string name, string value, HtmlTextWriterAttribute key) {
     AddAttribute(name, value, key, false, false);
 }
		/// <summary>
		/// Initializes a new instance of the HtmlAttribute class.
		/// </summary>
		/// <param name="attribute">The attribute.</param>
		/// <param name="value">The value of the attribute.</param>
		public HtmlAttribute(HtmlTextWriterAttribute attribute, string value)
		{
			this.Name = attribute.ToString().ToLower();
			this.Value = value;
		}
 public static HtmlTextWriter Attribute(this HtmlTextWriter writer, HtmlTextWriterAttribute attribute, string content = "")
 {
     writer.AddAttribute(attribute, content);
     return writer;
 }
 protected bool IsAttributeDefined(HtmlTextWriterAttribute key, out string value) {
     value = null;
     for (int i = 0; i < _attrCount; i++) {
         if (_attrList[i].key == key) {
             value = _attrList[i].value;
             return true;
         }
     }
     return false;
 }
 private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool encode) {
     RegisterAttribute(name, key, encode, false);
 }
 protected virtual bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key) {
     return true;
 }
Ejemplo n.º 58
0
		protected override bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key)
		{
			// FIXME:
			// I checked every possible HtmlTextWriterAttribute key
			// and always throws ArgumentNullException.
			return (bool) attr_render [null];
		}
Ejemplo n.º 59
0
		public string PublicGetAttributeName (HtmlTextWriterAttribute attrKey)
		{
			return GetAttributeName (attrKey);
		}
Ejemplo n.º 60
0
		public bool PublicOnAttributeRender (string name, string value, HtmlTextWriterAttribute attr)
		{
			return OnAttributeRender (name, value, attr);
		}