Hi All,
I am looking for a way to set the border color of ComboBox from code behind using PreRender handler of the ComboBox. I have tried the following code and it does not work. Can someone please help me with this?
Regards,
Prasad
I am looking for a way to set the border color of ComboBox from code behind using PreRender handler of the ComboBox. I have tried the following code and it does not work. Can someone please help me with this?
protected void rcbMyCombo_PreRender(object sender, EventArgs e){ rcbMyCombo.BorderColor = System.Drawing.Color.Red; rcbMyCombo.ToolTip = "Error occurred with the data of the control.";}
Regards,
Prasad
4 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Apr 2012, 05:58 AM
Hi Prasad,
Please try setting BorderWidth to get the border as follows.
C#:
Hope this helps.
Thanks,
Princy.
Please try setting BorderWidth to get the border as follows.
C#:
protected void rcbMyCombo_PreRender(object sender, EventArgs e) { rcbMyCombo.BorderWidth = Unit.Pixel(1); rcbMyCombo.BorderColor = System.Drawing.Color.Red; rcbMyCombo.ToolTip = "Error occurred with the data of the control."; }Hope this helps.
Thanks,
Princy.
0
Prasad
Top achievements
Rank 1
answered on 18 Apr 2012, 06:20 AM
Thank you for your help. It worked.
Regards,
Prasad
Regards,
Prasad
0
Wayne
Top achievements
Rank 1
answered on 17 Apr 2018, 12:03 AM
Thanks for this. How does one remove a set colour. that is reset back to none.
In my case it is the BackColour I am working with.
0
Hello Wayne,
Regards,
Marin Bratanov
Progress Telerik
I have just answered your support ticket with the same question and I am pasting the information here for anyone else having the same issue.
As a general rule I would recommend using the CssClass and stylesheets to change the colors: https://docs.telerik.com/devtools/aspnet-ajax/general-information/controlling-visual-appearance/overview.
The BackColor inherits the value of the control parent, so you can reset it to the .Parent.BackColor value. For example:
<asp:Panel runat="server"> <telerik:RadTextBox runat="server" ID="rtb1"></telerik:RadTextBox></asp:Panel><asp:Button Text="reset back color" ID="Button1" OnClick="Button1_Click" runat="server" />protected void Button1_Click(object sender, EventArgs e){ //important: the cast and control hierarchy may differ in your case rtb1.BackColor = (rtb1.Parent as System.Web.UI.WebControls.WebControl).BackColor;}protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { rtb1.BackColor = System.Drawing.Color.Red; }}
Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.