Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:48:18+00:00 2026-06-10T07:48:18+00:00

I have a user control with an asp.net server side button control in it.

  • 0

I have a user control with an asp.net server side button control in it. I use this user control on multiple pages. I am raising a custom event on the button click event of the usercontrol. All the parent pages using this usercontrol should get notified of this custom event that I raise from the usercontrol. Is there an easy way for me to get notified of this custom event in the parent pages other than subscribing to this event in all the parent pages?

I tried subscribing to this usercontrol event in an abstract base class that overrides the OnLoad() event of the parent pages and have all the parent pages inherit from this abstract base class. Usercontrol code behind is:

public partial class CustomPaging : System.Web.UI.UserControl
    {
         public delegate void NavigationButtonHandler(int currentPage);

         public event NavigationButtonHandler NavigationButtonClicked;
         public int CurrentPage { get; set; }

         protected void btnPrev_ServerClick(object sender, EventArgs e)
        {
            if (NavigationButtonClicked != null)
            {


                    NavigationButtonClicked(CurrentPage);


            }
        }

  }

And the abstract base class is:

public abstract  class CustomPagingBase 
    {

        protected override void OnLoad(EventArgs e)
        {

                 base.OnLoad(e);
                ((CustomPaging)this.FindControl("ucPaging")).NavigationButtonClicked += new CustomPaging.NavigationButtonHandler(CustomPagingBase_NavigationButtonClicked);
        }

        void CustomPagingBase_NavigationButtonClicked(int currentPage)
        {
            LoadData(currentPage);
        }

        protected abstract void LoadData(int currentPage);


    }

But the piece this.FindControl("ucPaging") returns null. Please note that I have a usercontrol with an id of ucPaging that I set declaratively in the parentpage’s markup

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:48:20+00:00Added an answer on June 10, 2026 at 7:48 am

    FindControl does not search recursively by default.

    So unless your ucPaging control was added directly to the controls collection that implements your abstract class you would get a null.

    You can use this function to find it

        public static Control FindControlRecursive(this Control control, string id)
        {
            if (control == null) return null;
            //try to find the control at the current level
            Control ctrl = control.FindControl(id);
            if (ctrl == null)
            {
                //search the children
                foreach (Control child in control.Controls)
                {
                    ctrl = FindControlRecursive(child, id);
                    if (ctrl != null) break;
                }
            }
            return ctrl;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET user control (.ascx file). In this user control I want
I have an asp.net user control on which I want to use jquery ajax.
I used to have an embedded user control in an ASP.NET web site which
I have an asp.net user control, userControl1.ascx, and another user control, userControl2.ascx. userControl2 is
I have a Web User Control that contains a CheckBoxList. MyListControl: <asp:checkboxlist id=chkList runat=server>
I have an ASP.NET 2.0 page with many repeating blocks, including a third-party server-side
We have created a User Control for ASP.Net. At any one time, a user's
I have a simple asp.net user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=QueryDefinitionItem.ascx.cs Inherits=xxx.UserControls.QueryDefinitionItem %>
I am developing a user control and it has an asp.net button inside jQuery
I have an ASP.NET page with two instances of the same Web User Control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.