Note that there are some explanatory texts on larger screens.

plurals
  1. POasp:Button not responding to clicks with OnClick
    text
    copied!<p>I seem to be having a problem with my button's OnClick, it doesn't even react at all to the event. It responds to OnClientClick and executes the code, but when I try to relate it o a function in my .aspx.cs class it just ignores it, and it should be executing very simple code (writing to the output debug)</p> <p>I've checked every other stackoverflow post about this I could find and no one had the same issue.</p> <p>I know that my Index.aspx is executing the code inside Index.aspx.cs because the Page_Load function is outputting to the debug window, so that's not the problem.</p> <p>Here's the important code:</p> <pre><code> &lt;asp:Button ID="btnCreateOrder" runat="server" Text="Create Order" OnClick="btnClick" /&gt; protected void btnClick(object sender, EventArgs e) { System.Diagnostics.Debug.Write("Testing3"); } </code></pre> <p>Like I said the Page_Load function is working fine so it's not an issue of them not being connected.</p> <p>DIFFERENT PROBLEM IF YOU FEEL SO INCLINED:</p> <p>While you're reading, I also have a problem of not being able to find objects from my HTML in my CS file.</p> <p>What I mean by that is, if I reference this label:</p> <pre><code> &lt;asp:Label ID="testLabel" runat="server" Text="test"&gt;&lt;/asp:Label&gt; </code></pre> <p>by saying</p> <pre><code> testLabel = "Test2"; </code></pre> <p>I get the error "The name 'testLabel does not exist in the current context"</p> <p>And if I try to reference it by saying this:</p> <pre><code> Index.testLabel = "Test2"; </code></pre> <p>I get "'MyProject.Views.Home.Index' does not contain a definition for 'testLabel'" even though it clearly does.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload