0

I found really nice color picker jscolor.com to use instead of the one that AJAX Toolkit provides.Installation is really piece of cake but now I have trouble with AsyncPostback. Every time any control does AsyncPostback my ColorPicker stops working,here is code:

   <asp:TextBox ID="TextColorSample" runat="server" Width="30px"></asp:TextBox>
                                    <asp:TextBox ID="TextColor" runat="server" OnTextChanged="TextColor_TextChanged"></asp:TextBox>
                                    <input type="button" class="color {valueElement:'TextColor',styleElement:'TextColorSample',hash:true,required:false}" />

So after postback, nothing happens anymore when I press button(picker should popup) and TextColorSample lose background Color that picker set before Postback. Can anyone explain to me what might be happening and how to fix it?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
formatc
  • 4,261
  • 7
  • 43
  • 81
  • After some more digging I found a duplicate: http://stackoverflow.com/questions/1952817/asp-net-javascript-inside-ajax-updatepanel – formatc Feb 04 '12 at 17:17
  • Please don't prefix your titles with things like "ASP.NET C#". That's what the tags are for. – John Saunders Feb 04 '12 at 17:38
  • @ John Thanks for pointing me to it, I see so much people doing that so I thought that's the right way to format title besides tags. – formatc Feb 04 '12 at 19:57

2 Answers2

0

Could you try this? This helped me.

<script>
 $(document).on('click', '#myPickerId', function () {
    var obj = $(this)[0];
    if (!obj.hasPicker) {
        var picker = new jscolor.color(obj, {});  //
        obj.hasPicker = true;
        picker.showPicker();
    }
});    
</script>

In my case, the picker control was dynamic because it is inside Knockout.js 'with' statement which hides and recreates the picker when it needs.

Maxim Eliseev
  • 3,248
  • 4
  • 29
  • 35
0

This reinitialize/rebind the colour picket with input controls.

jscolor.init();

Call it after success of ajax call.

Shanker Paudel
  • 740
  • 1
  • 9
  • 21