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 6542819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:16:23+00:00 2026-05-25T11:16:23+00:00

How does one actually expose a abstracted event from asp.net usercontrol[ascx file] to the

  • 0

How does one actually expose a abstracted event from asp.net usercontrol[ascx file] to the container webforms page. This is my scenario,

  1. I created a webforms usercontrol a ascx file and put a databound checkboxlist with a validator to validate it(I know this could be done webforms itself why a usercontrol u ask, but it’s a scenario)

  2. Now i wanted to expose a event to the container page called OnValidating which would produce the result of validation

signature of the event is below:

public delegate void Validating(object source,EventArgs e);

public event Validating OnValidating;

public void InvokeOnValidating(EventArgs e)
        {
            Validating handler = OnValidating;
            if (handler != null) handler(this, e);
        }

As per the msdn documentation, the page framework handles the event subscribing and unsubscribing. So all i need to do was invoke the event when validation fails. Great i was happy but,

  1. I couldn’t show up the event in the properties window when all other public propertes did

  2. Why the hell is my event invoker[InvokeOnValidating], event delegate[Validating] shown in intellisense list when i type usercontrolid. along with the event[OnValidating]. I want only the event to be exposed.

  3. Also can i allow page to subscribe to event TextboxChanged created inside the usercontrol? If so get me the code.

Note: I would love to see more code than lengthy explanations

  • 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-05-25T11:16:24+00:00Added an answer on May 25, 2026 at 11:16 am

    You’re mixing concepts, you don’t need a delegate to register events, try this code, and i’ll explain the changes and attempt to answer your questions below

        public event EventHandler Validating;
        private void OnValidating(EventArgs ea)
        {
            var e = Validating;
            if (e != null)
                e(this, ea);
        }
    

    On the page with the control use, notice the On, the framework adds this for all events:

    <uc:MyUserControl OnValidating="myhandlermethodinpage" />
    
    1. VS is not 100% accurate with this, sometimes properties of controls don’t show up! Intelissence is more reliable
    2. Because they weren’t set as private, only the event should be public.
    3. Not sure that will be possible, you’ll need to capture the event of the textbox in the control and make it raise it’s own new event.

    Couldn’t add on comment, but basically if you need custom event args do as such:

        public event EventHandler<CustomEventArgs> Validating;
    private void OnValidating(CustomEventArgs ea)
    {
        var e = Validating;
        if (e != null)
            e(this, ea);
    }
    public class CustomEventArgs:EventArgs{
        public int MyProperty { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What does setting SubClassFetchMode e.g. to EAGER_PARALLEL actually do? Why would one want a
How does one convert an image from one color profile to another (screen to
How does one return from a closure, without returning from the containing function? In
This may be a stupid question but how does one actually run the 'Build'
I'm a bit new to ASP.NET. Actually, I'm a marginalized VB/SQL programmer who is
I'm trying to figure out where does the initial sys.path value come from. One
I have an ASP.NET app that exposes a Microsoft ReportViewer (actually an MVC3 app
How does one access unique_ptr elements of a container (via an iterator) without taking
I am making a timetabling program which does one to one matches from SubjectTeacherPeriod
does one perform better over the other in terms of indexing/quering etc ? e.g.

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.