如何从代码后面更改AJAX ColorPickerExtender

时间:2017-05-19 08:04:02

标签: javascript asp.net ajax ajaxcontroltoolkit

我有这段代码:

                   <div class="entryrow">
                    <div class="input" style="width: 40%;">
                        <asp:TextBox ID="txtColor" runat="server" Width="95%" Font-Size="Large"></asp:TextBox>&nbsp;
                    </div>
                    <div class="input">
                        <asp:ImageButton ID="imgbtnColorPicker" runat="server" ImageUrl="~/images/icons/colorpicker.png" />&nbsp;
                    </div>
                    <ajaxToolkit:ColorPickerExtender runat="server" ID="cpBackgroundColor" TargetControlID="txtColor" OnClientColorSelectionChanged="colorChanged"
                        SampleControlID="imgbtnColorPicker" PopupButtonID="imgbtnColorPicker" />
                    <div class="clear"></div>
                </div>

               <asp:HiddenField ID="hfColor" runat="server" />

和js:

    function colorChanged(sender) {
        sender.get_element().style.color =
             "#" + sender.get_selectedColor();
    };

如何在加载页面时从后面的代码中设置ColorPickerExtender颜色。从代码中我获取此元素的当前颜色并将其放在隐藏字段中。如何在ColorPickerExtender中触发有关更改颜色的事件?

0 个答案:

没有答案