Skip to content Skip to sidebar Skip to footer

Asp.net How Do I Get This Jquery To Work Persistently Across Page Loads / Post Backs?

In ASP.NET I'm trying to use mColorPicker (http://blog.meta100.com/post/600571131/mcolorpicker) with a page I have. It works on initial page load, can pick the colors fine and I h

Solution 1:

I am assuming that you use updatepanels, in that case you can use the page request manager which manages partial page updates. Like this:

//some initialization codevar prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_endRequest(function (sender, args) {
    //some initialization code
});

Solution 2:

It appears you are using update panels (I am assuming because of the pageLoad function). So remember whatever you run on $(document).ready, you will also need to run in the pageLoad funciton (if the content is replace).

Solution 3:

Assuming you're using the latest* jQuery, try this snippet, but put it outside the update panel: (assuming #color3 will only show up once, if you need it to work on a class of elements you should define a ... class)

<scripttype="text/javascript">
  $(document).ready(function () {
    $('#color3').live('colorpicked', function () {
      $(".P_FrameDisplay_222").css("background-color", $(this).val());
    });
  });
</script>
  • As of jQuery 1.4 the .live() method supports custom events as well as all JavaScript events that bubble. [emphasis mine]

Post a Comment for "Asp.net How Do I Get This Jquery To Work Persistently Across Page Loads / Post Backs?"