Color Picker save/load values

2 posts, 0 answers
  1. Nelson
    Nelson avatar
    6 posts
    Member since:
    Jun 2010

    Posted 12 Oct 2011 Link to this post

    I'm trying to use the color picker to load and save values. My values are stored in normal HTML format (#000000). The demos show that you can set the selected color in the control property like so: SelectedColor = "#000000" however the property is really a System.Drawing.Color type. You cannot set the property like this: ColorPicker.SelectedColor = "#000000"; in the code. Instead you must convert the HTML string to System.Drawing.Color.

    This seems so basic, I think I must be missing something. Are there no built in routines to allow us to easily load and save HTML colors or do we really have to convert everything to and from the database?

    Can you give me two examples of the recommended way of setting and getting an HTML color value from code?
  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 17 Oct 2011 Link to this post

    Hello Nelson,

    Currently you can get and set the current color of a RadColorPicker programmatically only through a System.Drawing.Color type. Nevertheless, you can easily convert a hex color code to and from a System.Drawing.Color through the static methods FromHtml and ToHtml of the System.Drawing.ColorTranslator class. For your convenience I have attached a sample page, demonstrating getting and setting an HTML color value from code. Please use it as a reference for your further development.

    I hope that helps.

    Kind regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top