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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:28:54+00:00 2026-05-25T01:28:54+00:00

I have ascx suppose A.ascx in which i am writing a delegate on OnInit()

  • 0

I have ascx suppose A.ascx in which i am writing a delegate on OnInit() like this

  btnUpdate.Click += delegate
                               {
                                   if (MaxLength.HasValue && txtText.Text.Length >= MaxLength.Value)
                                   {
                                       lblError.Text = string.Format(Resources.ErrorMessage_FieldLength, MaxLength);
                                       return;
                                   }
                                   if (Update != null) Update(this, EventArgs.Empty);
                               };

Now I want to call this delegate on B.ascx btn click

protected void btnHdnAnswer_Click(object sender, EventArgs e)
    {
       // How to call above delegate..  

    } 

Please help me in this

  • 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-25T01:28:54+00:00Added an answer on May 25, 2026 at 1:28 am

    Make your delegate a proper method.

    btnUpdate.Click += delegate { DoUpdate(); }
    ...
    
    public void DoUpdate()
    {
        if (MaxLength.HasValue && txtText.Text.Length >= MaxLength.Value)
        {
           lblError.Text = string.Format(Resources.ErrorMessage_FieldLength, MaxLength);
           return;
        }
        if (Update != null) Update(this, EventArgs.Empty);
    }
    

    Make sure the Id of your control is set to generate a member for it in the code-behind:

    <Project:A runat="server" ID="MyBControl"/>
    

    Then call it from your B (parent) control:

    protected void btnHdnAnswer_Click(object sender, EventArgs e)
    {
        MyBControl.Update();
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ascx that uses Eval in a repeater like this: <%@ Control
I have an Ascx control which I reload every Page_load using Loadcontrol . This
For example, i have this ImageViewer.ascx UserControl: <div class=ImageTumbnails> <asp:ListView ID=ImageList runat=server ItemPlaceholderID=ItemContainer> <LayoutTemplate>
I have made a basic ascx control which is just a panel with a
I have an ASP.NET user control (.ascx file). In this user control I want
I have ascx partial view with html-layout like that <%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ...
I have an ascx control which contains dropdownboxes I want to be able to
I have LogOn.ascx control which is located on master page site.master: <% Html.RenderPartial(LogOn); %>
I am trying to edit a control which doesn't have an .ascx page, it
I have many ascx control files in which I am using the tinymce editor

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.