title: ASP.NET Core Razor Pages - Disable all the buttons on multiple forms
body: <p>I’m working on ASP.NET Core Razor Pages
  and I'm trying to disable all the buttons on the page when a button is clicked.
  My code looks something like this:</p>
  <pre><code>&lt;form method=&quot;post&quot; onsubmit=&quot;DisableBtns()&quot;&gt;
  &lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot; name=&quot;btn1&quot; &gt; &lt;/button&gt;
  &lt;/form&gt;
  
  
  &lt;form method=&quot;post&quot; onsubmit=&quot;DisableBtns()&quot;&gt;
  &lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot; name=&quot;btn2&quot; &gt; &lt;/button&gt;
  &lt;/form&gt;
  
  
  &lt;script&gt;
      function DisableBtns() {
          alert(&quot;The form was submitted&quot;);
          btn1.disabled = true; btn2.disabled = true; return true;
      }
  &lt;/script&gt;
  </code></pre>
  <p>My problem is the alert did execute but the buttons are not disabled.</p>
  <p>The following code does work but I don't want it I want to use the function way:</p>
  <pre><code>&lt;form method=&quot;post&quot; onsubmit=&quot;btn1.disabled = true; btn2.disabled = true; return true;&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Can someone please help me resolve this issue or if you have a better way that works on Razor Pages I would really appreciate it.</p>