Button OnClick () Event not burning

I have an asp.net page where I am making an add that requires me to add another button event. In the example below, btnTwo and btnThree fire their events and OnClick () functions as they should. However, when I added btnOne with its associated OnClick () event, the dose does not trigger the breakpoint that I set for the String test. I checked the page during project startup and noticed that btnTwo and btnThree have onpick dopostbackwithoptions in the control, but btnOne is not a dose. Also, when btnOne is pressed, pageload events are also not fired. I don't know what is going on with this or what I am doing wrong. I've also tried to do a clean build of the solution as it was recommended by another online resource, but it still doesn't function as it should.

Page:

<table style="width: 210px" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td style="padding-right: 50px">
            <asp:Button ID="btnOne" runat="server" CssClass="DefaultButton" Width="120px" OnClick="btnOne_Click" />
        </td>
        <td style="padding-right: 50px">
            <asp:Button ID="btnTwo" runat="server" ValidationGroup="QtyGroup" CssClass="DefaultButton" Width="90px" OnClick="btnTwo_click" />
        </td>
        <td>
            <asp:Button ID="btnThree" runat="server" CssClass="DefaultButton" Width="90px" OnClick="btnThree_click" />
        </td>
    </tr>
</table>

      

CodeBehind:

protected void btnOne_Click(object sender, EventArgs e)
    {
        string test = "";
    }

      

+3


source to share


4 answers


I bet your button event fires, but your debug doesn't fire. I saw this when I was linking the solution to iis incorrectly. In your case, add the code to update the shortcut and I'm pretty sure it works. Check your URL. I saw when my IIS binding is wrong the url changes from localhost: someport to dns name. This can result in the debug points not being triggered.



+2


source


Restart VS and then remove the event name from the .aspx page and create a new event again. VS has some problems a few times. Sometimes it worked for me.



+1


source


Try changing the access modifier to public

and see if it doesn't matter. I've noticed similar behavior in WPF.

I also noticed that the event handlers for btnTwo and btnThree are lowercase click

in the method name. I'm not sure if you entered the code manually here or copied / pasted it. Make sure the names match.

+1


source


Have you copied this method from another page / application? If yes then it won't work, so you need to remove the event name and event assigned to the button, then go to design and go to the properties of the button to go to the onClick event, double click next to it, it will generate an event and automatically assign the name of the event for the button. this should work

+1


source







All Articles