How to display child user controls in a specific place?

I have a very simplified user control that looks like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="wfWindow.ascx.cs" Inherits="webfanatix.co.za.wfWindow" %>
<div>Just a test...[x]</div>

with this code behind:

[ParseChildren(false)]
[PersistChildren(true)]
public partial class wfWindow : System.Web.UI.UserControl
{
    protected override void Render(HtmlTextWriter writer)
    {
        RenderChildren(writer);
    }
}

And its use is as follows:

<wf:wfWindow runat="server">This content should go where [x] is.</wf:wfWindow>

I'm not ASP.NET pro, so how do I get the content to render, where [x] appears in my user control?

RenderChildren provides my content, but it is only added to the end of UserControl output. I need him to sit right where [x] marks the place.

Thanks in advance!

+3
source share
2 answers
+1

[X] , , .

AddParsedSubObject(). controlcontrolcontrol, , . , placeholder.

   protected override void AddParsedSubObject(Object obj) 
   {
         PanelWhereXIs.Add(obj);
   }
+2

Source: https://habr.com/ru/post/1727697/


All Articles