Miscellaneous in EJ 1 ASP.NET MVC ColorPicker

24 May 2017 / 1 minute to read

getValue

The getValue() method in ColorPicker returns the hexadecimal value.

  1. In the CSHTML page, configure the ColorPicker widget as follows.
@*In the CSHTML page, add the HTML helpers to render ColorPicker widget*@
 @Html.EJ().ColorPicker("colorPicker").Value("#278787")
<script> 
  var ColorObj;
  jQuery(function ($) { 
	ColorObj = $("#colorPicker").ejColorPicker({ value: "#278787" }).data('ejColorPicker');
	ColorObj.getValue();  
  });
</script>

setValue

The setValue() method in ColorPicker is used to set the color value. The given value is in hexadecimal form.

  1. In the CSHTML page, configure the ColorPicker widget as follows.
@*In the CSHTML page, add the HTML helpers to render ColorPicker widget*@
 @Html.EJ().ColorPicker("colorPicker")
<script>  
	 var ColorObj;
	 jQuery(function ($) {  
	 ColorObj = $("#colorPicker").ejColorPicker().data('ejColorPicker'); 
	 ColorObj.setValue("#278787"); 
	 });
</script>

getColor

The getColor() method in ColorPicker control returns the color value in r,g,b,a form.

  1. In the CSHTML page, configure the ColorPicker widget as follows.
@*In the CSHTML page, add the HTML helpers to render ColorPicker widget*@ 
@Html.EJ().ColorPicker("colorPicker").Value("#278787")
<script> 
	 var ColorObj; 
	 jQuery(function ($) { 
	 ColorObj = $("#colorPicker").ejColorPicker({value: "#278787" }).data('ejColorPicker'); 
	 ColorObj.getColor();
	 });
</script>