# .NET and More > ASP.NET And ASP.NET Core >  Trigger button_click via checkbox

## sking

Hi there,

I have been trying to use an asp checkbox to trigger the code of a regular button on the same page. I"m going to remove the button, however I want the same code to be run when a checkbox is checked or the text changes in a textbox. 

Can a checkbox fire the button_click for the button?  My code isn't working.

                <asp:CheckBox ID="cbchargesnotongfe10pfc" runat="server" AutoPostBack="true" OnCheckedChanged="Button1_Click" />&nbsp; <-this is not working
                <asp:CheckBox ID="cbchargesnotongfe10f" runat="server" />&nbsp;
                <asp:CheckBox ID="cbchargesnotongfe10poc" runat="server" onchange="totalcharges()" />&nbsp;  <- this run javascript fine
                <asp:CheckBox ID="cbchargesnotongfe10fin" runat="server" onchange="totalcharges()" />&nbsp;    <- this run javascript fine

  Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Dim feearray As String()

Also, how would firing the same code work when the text is changed in a textbox? If I use this code:
asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>

can I direct every textbox on the page to the same codebehind, or does each textbox have to have it's on codebehind? I want every checkbox and textbox to fire the same codebehind sub.

----------


## .paul.

You can use one handler for many textboxes. I dont see what youre saying about the checkboxes? They dont have a TextChanged event. You could probably use the same event for the checkedchanged event of the checkboxes

----------


## .paul.

Its also possible to handle the appropriate event of controls in separate multiple control handlers, then call the same method (sub) from all of your handlers. Mixed multi-handlers only work if the eventhandler has the same arguments passed to it

----------


## .paul.

Strictly speaking, you'll get better help in the Asp.Net forum...

https://www.vbforums.com/forumdispla...d-ASP-NET-Core

I'll ask a moderator to move your thread.

----------

