title: intercept __doPostBack function
body: <p>According to this <a href="https://stackoverflow.com/questions/2234542/how-to-intercept-any-postback-in-a-page-asp-net">post</a> you can intercept the post by overriding this function  <code>__doPostBack</code> but it wont work. If I view the generated source I am not able to see the function that is meant to be auto generated and causes asp.net to make the postback.</p>
  
  <p>where is this function? and how do I intercept it?</p>
  
  <p>I'm using asp.net 4 and vs 2012</p>
  
  <p>Default.aspx</p>
  
  <pre><code>&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;script&gt;
          //breaks here as it cant find __doPostBack
          var __original = __doPostBack;
          __doPostBack = myFunction();
  
          function myFunction() {
  
              alert('intercept');
  
          }
  
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:TextBox ID="TextBox1" runat="server" &gt;&lt;/asp:TextBox&gt;
  
          &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Default.aspx.vb</p>
  
  <pre><code>Partial Class _Default
      Inherits System.Web.UI.Page
  
      Protected Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
  
      End Sub
  
      Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          Dim txt As String = TextBox1.Text
  
      End Sub
  End Class
  </code></pre>