Now I’m going to explain how
to use Ajax ColorPicker in ASP.NET. Ajax ColorPickerExtender provides
client-side color-picking functionality with UI in a popup control.First you
will add ajaxtoolkitcontrol.dll reference in your project. And give the below
code in your aspx page.
<%@
Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="actk"
%>
<asp:Content
ID="HeaderContent"
runat="server"
ContentPlaceHolderID="HeadContent">
<script type="text/javascript">
function
Color_Changed(sender) {
sender.get_element().value = "#" + sender.get_selectedColor();
}
</script>
</asp:Content>
<asp:Content
ID="BodyContent"
runat="server"
ContentPlaceHolderID="MainContent">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="txtColor" runat="server" Width="150px" />
<br />
<div id="PreviewColor" style="width: 50px; height: 50px; border: 1px solid Gray">
</div>
<asp:Button ID="btnPicker" runat="server" Text="Choose Color" />
<actk:ColorPickerExtender ID="ColorPicker1" runat="server" TargetControlID="txtColor"
SampleControlID="PreviewColor" PopupButtonID="btnPicker" PopupPosition="Right"
OnClientColorSelectionChanged="Color_Changed" />
</div>
</asp:Content>
Then run your project, The result will display same as given below.
No comments:
Post a Comment