Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I load two ASP.NET UserControls on Demand?
    primarykey
    data
    text
    <p>I want load two user controls on demand.</p> <pre><code> asp:UpdatePanel ID="UpdatePanel1" runat="server" ContentTemplate asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="Button1_Click" / div id='Div_UserControlPlace' enableviewstate="true" runat="server" /div /ContentTemplate Triggers asp:PostBackTrigger ControlID="Button1" / /Triggers /asp:UpdatePanel asp:UpdatePanel ID="UpdatePanel2" runat="server" ContentTemplate asp:Button ID="Button2" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="Button2_Click" / div id='Div_UserControlPlace2' enableviewstate="true" runat="server" /div /ContentTemplate </code></pre> <p>aspx.cs</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Control FeaturedProductUserControl = new Control(); FeaturedProductUserControl = LoadControl("WebUserControl1.ascx"); FeaturedProductUserControl.EnableViewState = true; Div_UserControlPlace.Controls.Add(FeaturedProductUserControl); } protected void Button2_Click(object sender, EventArgs e) { Control FeaturedProductUserControl2 = new Control(); FeaturedProductUserControl2 = LoadControl("WebUserControl2.ascx"); FeaturedProductUserControl2.EnableViewState = true; Div_UserControlPlace2.Controls.Add(FeaturedProductUserControl2); } </code></pre> <p>I load the first user control by clicking on the first button - this works properly but when I click on the other button to load the second UserControl, the first UserControl disappears and the second UserControl loads.</p> <p>Thanks IFA_User</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload