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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:32:08+00:00 2026-06-12T01:32:08+00:00

I am constructing a c#/.net website. The site uses master pages and update panels.

  • 0

I am constructing a c#/.net website.

The site uses master pages and update panels.

I have a situation where I have a usercontrol in the page, that needs to update a user control in the master page and vice versa.

I know how to construct a delegate between the usercontrol and the page, or usercontrol and master page, but i’m unsure about a couple of things as my knowledge of .net isn’t that great.

1) How to construct a delegate between usercontrol -> page -> master page (2 levels)
2) The same backwards usercontrol -> master page -> page

I’m not sure if any of the components of 1) and 2) could be shared. For instance a single delegate event that spans the 2 levels and works both ways.

I’d appreciate any advice/examples.

Thanks in advance.

  • 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-12T01:32:10+00:00Added an answer on June 12, 2026 at 1:32 am

    I cannot be too sure from your question, but perhaps you need to know that you can declare the delegate at the namespace level?

    namespace MyNamespace
    {
       public delegate void MyDelegate(object sender, EventArgs e);
    
       public class MyClass
       {
          public event MyDelegate OnSomethingHappened;
       }
    }
    

    EDIT
    I think I understand a bit better…see if this is what you are looking for:
    This is the code from the ‘.cs’ files of a Site.Master page, and a WebUserControl…the delegate is declared globally in the namespace, within the master page, and the user control declares an event of that delegate type:

    // MASTER PAGE
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplication4
    {
        public delegate void MyDelegate(object sender, EventArgs e);
    
        public partial class SiteMaster : System.Web.UI.MasterPage
        {
            // Here I am declaring the instance of the control...I have put it here to illustrate
            // but normally you have dropped it onto your form in the designer...
            protected WebUserControl1 ctrl1;
    
            protected void Page_Load(object sender, EventArgs e)
            {
                // instantiate user control...this is done automatically in the designer.cs page 
                // if you created it in the visual designer...
                this.ctrl1 = new WebUserControl1();
    
                // start listening for the event...
                this.ctrl1.OnSomethingHappened += new MyDelegate(ctrl1_OnSomethingHappened);
            }
    
            void ctrl1_OnSomethingHappened(object sender, EventArgs e)
            {
                // here you react to the event being fired...
                // perhaps you have "sent" yourself something as an object in the 'sender' parameter
                // or perhaps you have declared a delegate that uses your own custom EventArgs...
            }
        }
    }
    
    //WEB USER CONTROL
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplication4
    {
        public partial class WebUserControl1 : System.Web.UI.UserControl
        {
            public event MyDelegate OnSomethingHappened;
    
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            private void MyMethod()
            {
                // do stuff...then fire event for some reason...
                // Incidentally, ALWAYS do the != null check on the event before
                // attempting to launch it...if nothing has subscribed to listen for the event
                // then attempting to reference it will cause a null reference exception.
                if (this.OnSomethingHappened != null) { this.OnSomethingHappened(this, EventArgs.Empty); }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

TGIF, I have a website I'm developing which is using ASP.NET masterpage/sitemap/content pages setup.
I'm attempting to add a feature to an existing ASP.net web site that needs
I'm constructing an ecommerce application in Symfony, and I have a page which lists
I am building an asp.net website and I am constructing a Excel document based
I have written an ASP.NET MVC application that allows the user to specify their
I'm constructing a hql query that needs to return orders where the User's ID
We have an ASP.NET MVC app that sits on top of a Drupal database
I have a Lucene.net index where one of the fields receives many entries that
From my perspective, we're constructing our own 'flavour' of NAnt/Ivy/CruiseControl.Net in-house and can't help
I'm constructing a website for a small collection of parents at a private daycare

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.