0

Description:

I added updated to my asp.net page in which I am also using Jquery. But jquery stopped functioning when any partial postback occurs (document.ready() is not being invoked).

Sample code:

 <script type="text/javascript">
    $(document).ready(function () {
        $("SELECT").selectBox();

}

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
 <asp:Dropdownlist id="ddlproduct" runat="server"      onselectedindexchange="function"></asp:Dropdownlist>

Any suggestions

Thanks in advance

  • Please refer the similar question http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels – Shebin Aug 04 '11 at 06:50

1 Answers1

1

Since you're using a ScriptManager and UpdatePanel Use the ASP.NET AJAX pageLoad() function. It runs on Init and after EndRequest as well, so it will work both when you load up the page as well as on every update from an UpdatePanel.

You may want to put in a check to see if the dropdown has already been converted to the stylized dropdown though, for performance considerations.

<script type="text/javascript">
  function pageLoad() { 
    $("select").selectBox();
  }
</script>
Andy T
  • 87
  • 2