0

I am writing the javascript code to initialize a jquery plugin in my user control from the .ascx.cs file to be able to modify some options when I reload the plugin. Each time the plugin is loaded, I update a div with the new generated code. It is working fine, I can see the code updating but it is not being executed so my plugin does not take in consideration the new options.

ascx file :

<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
    <ContentTemplate>
        <div id="div_js" runat="server">

        </div>
    </ContentTemplate>
</asp:UpdatePanel>

ascx.cs file :

div_js.InnerHtml = "<script type=\"text/javascript\">"
    + "$(document).ready(function() {"
        + "$('#Grille_" + ID + "').DataTable({ etc ...

So the javascript should be executed when the page finished loading.

Stan
  • 391
  • 2
  • 5
  • 21
  • Is it because the page is not reloaded and only my plugin is updated ? Is there something like "$(document).ready()" but just when a part of the page is loaded ? – Stan Feb 29 '16 at 14:27
  • see the answer on the other question, is the same solution with yours – Aristos Feb 29 '16 at 14:28
  • in the `function EndRequest` you initialize again your javascript code – Aristos Feb 29 '16 at 14:29
  • I was already doing the following but it is not working (initialization / getInstance / add_endRequest) : var prm = Sys.WebForms.PageRequestManager.getInstance();prm.add_endRequest(function () { – Stan Feb 29 '16 at 14:41
  • I think that I have found my real problem. I thought that the properties of my user control were saved but it seems they are not, it seems that I have to use ViewState but I do not know how it works. – Stan Feb 29 '16 at 15:03

0 Answers0