Search code examples
javascriptjqueryasp.net.netupdatepanel

Update an UpdatePanel manually using JavaScript or jQuery


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)


Solution

  • 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>