We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Runtime Attributes for BaseElement using the html style tag (css)

Hi, I''m trying to do some runtime attribute changes to my BaseElements as they are selected. In particular, the "style" attribute for any html input tag (ie select, input, textarea). For example... this._htmlUIControl.Document.BeginUpdate(); textareaElement.Attributes["style"].Value = "background-color:yellow;" this._htmlUIControl.Document.EndUpdate(); *NOTE: Every element does have the style attribute within the attributes collection. However, I see no effect. I noticed that the style attribute has a IsRuntimeAttribute of false and I figure this is my problem. Is there any way around this such that I can place a background color to my input tags using the html style tag? Thanks, Brian

2 Replies

NR Nandakumar R Syncfusion Team September 13, 2005 04:54 AM UTC

Hi Brian, I was able to reproduce your problem. I have placed a feature request for the BeginUpdate() not showing the effect. Regarding adding styles at run time to the HTML elements, this can be done using two methods: 1) We can assign the styles directly by changing the value of the style attribute as shown below: textareaElement.Attributes["style"].Value = "background-color:yellow;" if you don''t have a style attribute, you can add the attribute with the help of the Add method as shown below: if(elem.Attributes.Contains("style") == false) elem.Attributes.Add("style"); I have attached a sample for this method. Please let me know if it helps. 34496_changestyle_style.zip 2) With the help of style tags, we can change the styles by changing the value of the class attribute as shown below: textareaElement.Attributes["class"].Value = "newStyle"; A sample that uses this method to add styles is attchaed below: 34496_changestyle_class.zip Hope it meets your requirements. We appreciate your patience. Thank you for your interest in the Syncfusion products. Regards, Nanda.


NR Nandakumar R Syncfusion Team September 13, 2005 05:02 AM UTC

Hi Brian, The link in the previous sample was broken. Please try this link, 34496_changestyle_class.zip Regards, Nanda.

Loader.
Live Chat Icon For mobile
Up arrow icon