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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:59:52+00:00 2026-06-01T09:59:52+00:00

So, I have a usercontrol with an update panel. I also put a button

  • 0

So, I have a usercontrol with an update panel.
I also put a button for updating the panel on my control.
I include this control 2 times (or more) in a page.
I want update only one of them but when I use the button, both panel is updated.

control ascx

    <script type="text/javascript">
  function bt_click()
  {        
     __doPostBack('UpdatePanel1', 'post');
     return false;
  }
  </script>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:HiddenField runat="server" ID="HiddenField1" Value="false" />
            <div>
                <asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

control .vb

protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Label1.Text = DateTime.Now.Ticks.ToString();
        }
    }

webform.aspx

<form id="form1" runat="server">
<div>
    <asp:Button runat="server" ID="bt" OnClientClick="bt_click" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    &nbsp;
    <asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
    <div>
        <My:MyControl ID="MyControl1" runat="server" />
    </div>
    <br />
    <div>
        <My:MyControl ID="MyControl2" runat="server" />
    </div>
</div>
</form>

webform.vb

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Label1.Text = DateTime.Now.Ticks.ToString();
    }
  • 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-01T09:59:54+00:00Added an answer on June 1, 2026 at 9:59 am

    EDIT FOR WORKING SOLUTION:

    Here’s what the error is: Your Button1 is outside of the UpdatePanels, thus posting back your page and all the controls with it. Hence both of them being updated. You can’t add the button in the Triggers section of your control, because obviously the control doesn’t know about it. So what you have to do is register that button as an Asynchronous PostBack Control. Here’s what I did:

    TestControl.ascx:

    Note: I had to add UpdateMode="Conditional" to the UpdatePanel, which yours did not have. By default, UpdateMode is set to Always, and that would cause us further issues.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestControl.ascx.cs" Inherits="Controls_TestControl" %>
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:HiddenField runat="server" ID="HiddenField1" Value="false" />
            <div>
                <asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    

    TestControl.ascx.cs:

    Note: I added UpdatePanel() as a property to get around needing to use your __doPostBack() calls in jQuery and I can easily access this from the parent page in the click event handler.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Controls_TestControl : System.Web.UI.UserControl
    {
    
        public UpdatePanel UpdatePanel() { return UpdatePanel1; } 
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                Label1.Text = DateTime.Now.Ticks.ToString();
            }
        }
    }
    

    Test.aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
    <%@ Register TagPrefix="uc" TagName="TestControl" Src="~/Controls/TestControl.ascx" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Fire UpdatePanel1" />
            <asp:Label ID="Label1" runat="server" Text="Val"></asp:Label>
            <br /><br />
            <uc:TestControl ID="TestControl1" runat="server" />
            <br />
            <uc:TestControl ID="TestControl2" runat="server" />
        </form>
    </body>
    </html>
    

    Test.aspx.cs:

    Note: Here is where I registered Button1 in the Page_Load with ScriptManager1.RegisterAsyncPostBackControl(Button1);

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager1.RegisterAsyncPostBackControl(Button1);
    
            if (!IsPostBack)
            {
                Label1.Text = DateTime.Now.Ticks.ToString();
            }
        }
    
        protected void Button1_Click(object sender, EventArgs e) 
        {
            TestControl1.UpdatePanel().Update();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a User control(ascx) that has an Update panel. When the page is
I have a page that contains a user control within an update panel. $(document).ready(function()
I have a dynamically created button that is being added to an update panel
I have a modal on a page that also contains a user control. When
I have a UserControl with a Border element within it that I want to
I have a UserControl that I want to add at runtime to my current
I'm creating user controls that i will put into an update panel and make
I have an ASP.NET Page that contains a User control called ReportCtrl (my own
I have an update panel which contains a table, to which I add rows
I have a UserControl called CustomerFinder for searhing customers. And there is "ADD" button

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.