Search code examples
c#asp.nettelerikasp.net-ajax

AJAX partial postback panel breaks my buttons?


So, I've been chasing this for a few days and I think I misdiagnosed the problem. I have an ASPX page with a few buttons and placeholders whose visibility changes based on queries. Everything works fine. But then I added a textbox with datetime from the server, inside an asp panel. The content within the panel works fine, and I've tried several scenarios.

Regardless of how I do it, I find that my buttons, which are outside of this panel, aren't working... I'm not getting to the click event at all. I've come to the conclusion that the partial postback is breaking the connections to my button clicks. Does this sound like a valid explanation and what can I do about it?

Edit to add, here's what I tried after your suggestion:

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

   var prm = Sys.WebForms.PageRequestManager.getInstance();

   prm.add_endRequest(function () {
       bindMyButtons();
   });

   function bindMyButtons() {
       $('CloseNoticeButton').click(function () {
           'CloseNoticeButton_Click()'
       });

       $('#InBtn').click(function () {
           'InBtn_Click'
       });
       $('#OutBtn').click(function () {
           'OutBtn_Click'
       });
       $('.MyClass').each(function () {
           //do stuff to the MyClass class
       });
   }

SOLVED! The suggestion to run it in F12 gave me the answer! I had to add: EnableEventValidation="false" to my page. Not entirely sure why but... it seems to work.


Solution

  • Running it in F12 gave me the answer... many thanks to @VDWWD! I had to add "EnableEventValidation="false" to may page. Not sure why but it solved the problem... knock on wood!