How to make Button Click event fire in usercontrol

I have an 2 web app. with an ASPX page linked to a master page.
There is NO code-behind page for the ASPX page.
I have placed a usercontrol in the ASPX page.  The usercontrol contains two gridviews and a button with code behind to bind the gridviews and a button click event.

The gridviews and databinding display fine when debugged. but I cannot get the usercontrol button event to fire.
Can anybody please provide a simple step-by-step guide to help me get the button click event to fire?
Thank you.
ASPX page:
<%@ Page Language="VB" MasterPageFile="~/Pages/MasterPage.master" Title="DW module - Data Analysis" %>

<%@ Register TagPrefix="DWM" Namespace="DWM" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<DWM:DWselector SkinFileName="DWmodule/DWselector.ascx" ID="DWselector1" runat="server" Secured="true" />

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

just make sure that the button click event is assigned the proper handler.
protected ....Button1_Click(....) Handles Button1.Click

or your button markup has ... OnClick="Button1_Click"

Note: Button1_Click could be something else but you get the idea...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Al230762Author Commented:
guru sami: in the code behind for the usercontrol I already have:
Protected WithEvents btnSelectAll As Button
Private Sub btnSelectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelectAll.Click

I should explain that the ASPX page has TWO usercontrols placed inside it and buttons on neither of the usercontrols work.

Can you explain to me why button events are fired when there is just ONE usercontrol on an ASPX page and why they do not fire when there are multiple usercontrols on the page?
-->Can you explain to me why button events are fired when there is just ONE usercontrol on an ASPX page and why they do not fire when there are multiple usercontrols on the page?

I don't know why it's behaving like that but may be you can try it in a new page...
Al230762Author Commented:
guru_same: that problem is now solved. I added the attributes for the button in the Page Load event and it now fires an event:

   If Not Me.IsPostBack Then
                             btnSaveSelection.Attributes.Add("onclick", "return clickButton(event,'" + btnSaveSelection.ClientID + "')")

Can you help with a supplementary problem. I now need to fire an event when a checkbox is clicked in one of the gridviews inside the usercontrol. I need to know how to raise that checkbox click event in the Page Load event as I did with the button (above) because the event is not firing if I code it in the ususal way (see attached code). Can you help with the code for that please?
ASCX page:
 <asp:GridView ID="grdGroups" runat="server" CssClass="text" AutoGenerateColumns="False" ForeColor="#333333" DataKeyNames="GroupID" AllowSorting="True" CellPadding="4" PageSize="5" Height="107px" Width="166px">
                        <asp:Label runat="server" ID="HeaderLevelCheckBox" Text="" />
<asp:CheckBox runat="server" ID="selectgroup" AutoPostBack="true" />

   Private Sub grdGroups_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdGroups.RowDataBound

            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim drv As DataRowView = DirectCast(e.Row.DataItem, DataRowView)
                Dim chk As CheckBox = DirectCast(e.Row.FindControl("selectgroup"), CheckBox)
                chk.Attributes.Add("OnCheckedChanged", "Checkbox1_CheckedChanged")
            End If

        End Sub

 Protected Sub Checkbox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        End Sub

Open in new window

not sure how to do exactly with VB.NET these changes should attach handler to OnCheckChanged...
1: Add AutoEventWireup="true" to your .asxc :

<%@ Control Language="VB" AutoEventWireup="true" ......%>

2: To your checkbox:
<asp:CheckBox runat="server" ID="selectgroup" AutoPostBack="true" OnCheckedChanged="Checkbox1_CheckedChanged" />

3: No need of this:
 chk.Attributes.Add("OnCheckedChanged", "Checkbox1_CheckedChanged")

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.