8 Answers, 1 is accepted
You can use the following approach:
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
.NoColorButton .rcpApplyButton
{
display: none !important;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadColorPicker
ID
=
"RadColorPicker1"
runat
=
"server"
CssClass
=
"NoColorButton"
PaletteModes
=
"HSV"
OnClientColorPreview
=
"OnClientColorPreview"
>
</
telerik:RadColorPicker
>
<
script
type
=
"text/javascript"
>
function OnClientColorPreview(colorPicker, args)
{
var color = args.get_color();
colorPicker._selectedColor = color;
colorPicker.updateClientState();
}
</
script
>
</
form
>
</
body
>
Regards,
Tsvetie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Hi Guys,
added to this - kind of the continuation to this question - When I set the selected colour in the code behind and want to change it in the front end I have to press the Reset/No Color Button first to "unlock" the colour field and hash code field (rcphexinput). Is there a way that the field starts changing immediately when moving the cursor (the same way it behaves if the SelectedColor property wasn't set).
In short I don't want to use any buttons at all neither for reset nor for apply.
Thanks
Pat
Hello Pat,
You should be able to immediately change the color. I am attaching here a small sample and a short video that show the expected behavior:
<
telerik:RadColorPicker
runat
=
"server"
ID
=
"RadColorPicker1"
PaletteModes
=
"All"
></
telerik:RadColorPicker
>
<
asp:Button
ID
=
"Button1"
Text
=
"get currently selected color"
OnClick
=
"Button1_Click"
runat
=
"server"
/>
<
asp:Label
ID
=
"Label1"
Text
=
""
runat
=
"server"
/>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
RadColorPicker1.SelectedColor = System.Drawing.Color.Red;
Button1_Click(
null
,
null
);
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
Label1.Text = RadColorPicker1.SelectedColor.ToString();
}
Can you confirm that the Selected Color is not being set again by another event or logic, that there are no JS errors and that you are using the latest version (R2 2016 SP1 at the time of writing)?
Regards,
Telerik by Progress
Hi Marin,
sorry for the late reply - I am currently traveling...
First of all - thanks for the awesome reply with the Video etc.!!! much appreciated - you guys rock!
Unfortunately I have to tell you the issue still persists, even in a brand new empty default VS Webforms application - here is what I did:
I downloaded the latest trial version (Q2 2016) and used the 4.5 dlls on a brand new out of the box Visual Studio 2013 Webforms project. When setting the selected colour in the code behind I still have to click the "No Color" Button to change the colour - which is very irritating for the user as for them it looks nothing is happening (until they reset via No Color).
Here is what I did on the empty aspx page
<telerik:RadColorPicker ID="ColourRadColorPicker" runat="server"
PaletteModes="HSB">
</telerik:RadColorPicker>
then in the code behind page load
if (!Page.IsPostBack)
{
ColourRadColorPicker.SelectedColor = Color.White;
}
and you will see the color doesn't change in the color preview unless I click the "No Color" button...
Many Thanks in advance
Cheers
Pat
Hi Pat,
Thank you for the additional information.
In this case, you get the expected behavior, because you start from White.
In the hue-brightness-saturation color space, this results in 100 (i.e., max) brightness. Thus, no matter what RGB color you start from, the color will always be white, because it is always so bright to become white.
If you start from Black, you will get the same behavior, you will always stay at 0 brightness (i.e., complete blackness) and it will not matter whether the color that is so black as to become red is supposed to be red, yellow, green or any other color.
Clicking on No Color changes the brightness value, so you can start changing RGB colors as a side effect.
Regards,
Telerik by Progress
Hi Marin,
No offence, I must admit I can follow your explanation - but to clients this looks like nothing is happening, even though it makes logically sense what you are saying.
Is there a way that we can change the "No Color" Button label to a button that says "Reset Colour" or so instead of an image that is shown?
Kind Regards
Pat
Hello Pat,
You can localize the tooltip of the button and/or you can use some JavaScript to change the button. Here is an example of both:
<telerik:RadColorPicker ID=
"ColourRadColorPicker"
runat=
"server"
PaletteModes=
"HSB"
RenderMode=
"Lightweight"
Localization-NoColorText=
"the tooltip for the no color button"
OnClientLoad=
"OnClientLoad"
>
</telerik:RadColorPicker>
<script>
function
OnClientLoad(sender, args) {
$telerik.$(
".rcpImageButton.rcpEmptyColor"
, sender.get_element()).html(
"some text"
).css(
"width"
,
"100px"
);
}
</script>
You can use the CSS selectors to hide the ::before element that holds the icon. For example:
.rcpImageButton.rcpEmptyColor:before
{
display
:
none
;
}
where you can cascade that through a custom CssClass you can set to this concrete color picker.
Regards,
Telerik by Progress
Hi Marin,
awesome - you guys rock!! - I put it in already!
Many Thanks
Pat