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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:31:04+00:00 2026-06-06T12:31:04+00:00

I am adding a user control dynamically on a page, the user control has

  • 0

I am adding a user control dynamically on a page, the user control has a save button that takes data from both user control and page to save in the DB, in the same save method i want to access a method wrriten in the page, so i that mehod had code to rebind the grid kept in the page.

So how can i call a page method in the dynamically added user control?

  • 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-06T12:31:05+00:00Added an answer on June 6, 2026 at 12:31 pm

    I was going to suggest creating a base class for your pages, but found an even better way to accomplish this task:

    http://www.codeproject.com/Articles/115008/Calling-Method-in-Parent-Page-from-User-Control

    Control code:

    public partial class CustomUserCtrl : System.Web.UI.UserControl
    {
        private System.Delegate _delWithParam;
        public Delegate PageMethodWithParamRef
        {
            set { _delWithParam = value; }
        }
    
        private System.Delegate _delNoParam;
        public Delegate PageMethodWithNoParamRef
        {
            set { _delNoParam = value; }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    
        protected void BtnMethodWithParam_Click(object sender, System.EventArgs e)
        {
            //Parameter to a method is being made ready
            object[] obj = new object[1];
            obj[0] = "Parameter Value" as object;
            _delWithParam.DynamicInvoke(obj);
        }
    
        protected void BtnMethowWithoutParam_Click(object sender, System.EventArgs e)
        {
            //Invoke a method with no parameter
            _delNoParam.DynamicInvoke();
        }
    }
    

    Page code:

    public partial class _Default : System.Web.UI.Page
    {
        delegate void DelMethodWithParam(string strParam);
        delegate void DelMethodWithoutParam();
        protected void Page_Load(object sender, EventArgs e)
        {
            DelMethodWithParam delParam = new DelMethodWithParam(MethodWithParam);
            //Set method reference to a user control delegate
            this.UserCtrl.PageMethodWithParamRef = delParam;
            DelMethodWithoutParam delNoParam = new DelMethodWithoutParam(MethodWithNoParam);
            //Set method reference to a user control delegate
            this.UserCtrl.PageMethodWithNoParamRef = delNoParam;
        }
    
        private void MethodWithParam(string strParam)
        {
            Response.Write(“<br/>It has parameter: ” + strParam);
        }
    
        private void MethodWithNoParam()
        {
            Response.Write(“<br/>It has no parameter.”);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m adding web user controls to a page dynamically. Using the LoadControl method that
Have a page that adds controls dynamically. Control state is being retrieved from database
I have a user control that I'm adding to a webpage dynamically. The ascx
I'm dynamically adding a custom user control to the page as per this post
I have a page where the user can dynamically add file upload boxes. Adding
When programmatically adding user controls using LoadControl(string path), when, in the user control's page
i have a aspx page on it i'm dynamically adding the web user controls
I have a grid view in web user control and I'm dynamically adding the
I have an aspx page that dynamically loads user controls: there is an UpdatePanel
I have a webpage that dynamically loads a user control. Each user control can

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.