Update an UpdatePanel manually using JavaScript or jQuery

Rush Frisby picture Rush Frisby · Aug 16, 2010 · Viewed 53k times · Source

Is it possible to update an UpdatePanel manually using JavaScript or jQuery?

What I have is a TextBox at the top of my page. When a user leaves that TextBox I want to run some server code (it will add a record to my database) then at the bottom of the page I have an UpdatePanel which will get refreshed. The UpdatePanel has a GridView which will have an entry for the record added)

Answer

Azhar picture Azhar · Aug 16, 2010

Just call this javascript function. Here UpdatePanel1 is updatepanel's ID

 <script type="text/javascript">

            var UpdatePanel1 = '<%=UpdatePanel1.ClientID%>';

            function ShowItems()
            {
               if (UpdatePanel1 != null) 
               {
                   __doPostBack(UpdatePanel1, '');
               }
            }       

        </script>