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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:57:33+00:00 2026-05-25T00:57:33+00:00

I have a form with an update panel, inside of the update panel is

  • 0

I have a form with an update panel, inside of the update panel is a div runat=”server”. I am dynamically adding user controls to this div. Inside of the user control is a link button. I would like to raise a Click event on this link button. I know that I must add the trigger dynamically as well. I am attempting to do this on the user control’s ‘Page_Load’ event using reflexion.

//Inside User Control
protected void Page_Load(object sender, EventArgs e)
{
this.Page.GetType().InvokeMember("AddTrigger", System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { this.lbDetails.UniqueID, "Click"});
}

//On the page
public void AddTrigger(string controlId, string eventName)
{
    AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
    trigger.ControlID = controlId;
    trigger.EventName = eventName;
    this.upContent.Triggers.Add(trigger);
}

This appears to be happening correctly, I can see the update panel triggers collection having the new trigger. Although, the trigger control name attribute does have the user control name as a prefix.. I am passing the uniqueId as the control name attribute for the async trigger (e.g. ctl11$lbDetails)… The Event is just ‘Click’. This does not appear to be working. When I click the linkButton the event handler method is not firing..

Thanks in Advance guys??

  • 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-25T00:57:34+00:00Added an answer on May 25, 2026 at 12:57 am

    Ok, I found a work around which does not involve using triggers or the scriptManager registry.

    This is the page

    <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
        Inherits="TestProject._Default" %>
    
    <%@ Register TagPrefix="uc" TagName="A" Src="~/UserControls/ucA.ascx" %>
    <html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <form id="Form1" action="Default.aspx" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="upMain" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
            <ContentTemplate>
                <div id="divContent" runat="server">
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="BtnClick" />
        <asp:PlaceHolder ID="phMain" runat="server">
        </asp:PlaceHolder>
        </form>
    </body>
    </html>
    

    This is the page code behind

    using System;
    using System.Collections.Generic;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using TestProject.UserControls;
    
    namespace TestProject
    {
        public partial class _Default : Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    divContent.InnerHtml =
                        "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante" + 
                        " dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce" +
                        " nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu" +
                        " ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim" +
                        " lacinia nunc. </p>" +
                        "<p>Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis" +
                        " tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus" +
                        " non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt" +
                        " sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia" +
                        " nostra, per inceptos himenaeos. </p>" +
                        "<p>Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis." +
                        " Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin" +
                        " quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque" +
                        " cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in" +
                        " faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. </p>" +
                        "<p>Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis" +
                        " laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices" +
                        " ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer lacinia sollicitudin" +
                        " massa. Cras metus. </p>" +
                        "<p>Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet," +
                        " augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu," +
                        " pede. Ut orci risus, accumsan porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci. Ut eu diam at pede suscipit" +
                        " sodales. Aenean lectus elit, fermentum non, convallis id, sagittis at, neque. Nullam mauris orci, aliquet et, iaculis et, viverra" +
                        " vitae, ligula. </p>";
    
                    //Clear session on first load
                    Session["controls"] = null;
                }
    
                if (Session["controls"] != null)
                {
                    RenderControls(Session["controls"] as List<Control>);
                    var postbackInit = GetPostBackControl(this);
                    LbClick(postbackInit, null);
                }
            }
    
            //Get Control that caused postback
            public static Control GetPostBackControl(Page page)
            {
                Control control = null;
    
                string ctrlname = page.Request.Params.Get("__EVENTTARGET");
                if (!string.IsNullOrEmpty(ctrlname))
                {
                    control = page.FindControl(ctrlname);
                }
                else
                {
                    foreach (string ctl in page.Request.Form)
                    {
                        Control c = page.FindControl(ctl);
                        if (c is Button)
                        {
                            control = c;
                            break;
                        }
                    }
                }
                return control;
            }
    
            public void Partial_Postback(ucA sender)
            {
                var counter = 5;
                var controls = new List<Control>();
                sender.Key = counter;
                sender.ID = counter.ToString();
    
                controls.Add(sender);
                Session["controls"] = controls;
                RenderControls(controls);
                sender.LbDetails.ID = counter.ToString();
            }
    
            private void RenderControls(List<Control> controls)
            {
                foreach (var control in controls)
                {
                    var controlReference = Page.FindControl(control.ID);
                    if (controlReference == null)
                    {
                        divContent.Controls.Add(control);
                    }
                }
                upMain.Update();
            }
    
            private void LbClick(object sender, EventArgs e)
            {
                divContent.InnerHtml = string.Empty;
                divContent.InnerText = string.Format("trigger works and ID = {0}", (sender as LinkButton).ID);
                upMain.Update();
            }
    
            public void BtnClick(object sender, EventArgs e)
            {
                var controlA = new ucA();
                controlA = (ucA)LoadControl("~/UserControls/ucA.ascx");
                divContent.Controls.Add(controlA);
            }
        }
    }
    

    This is the user control

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucA.ascx.cs" Inherits="TestProject.UserControls.ucA" %>
    
    <asp:LinkButton ID="LinkButton1" runat="server" ToolTip="This is the tool tip">Click Me to Remove Text</asp:LinkButton>
    

    This is the user control code behind

    using System;
    using System.Reflection;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace TestProject.UserControls
    {
        public partial class ucA : UserControl
        {
            public int Key;
    
            public LinkButton LbDetails
            {
                get { return this.LinkButton1; }
                set { LinkButton1 = value; }
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {
                Page.GetType().InvokeMember("Partial_Postback", BindingFlags.InvokeMethod, null, Page, new object[] { this });
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of update panels inside a user control. One of the
I have a basic CRUD form that uses PageMethods to update the user details,
I have a problem with Updating Form Element Look and Feel under Update Panel
I have a asp:panel on the root and a lot of controls inside. When
I have a donation form that contains an update panel that contains a dropdown
Let's say I have form A that contains a panel (with many other controls
My form-runat-server is inside of a masterpage, and I noticed the form id was
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have a form which is used to insert/display and update . In the
I have a form that I am using to try and update a field

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.