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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:35:40+00:00 2026-05-20T12:35:40+00:00

I need to develop a template-like user control, which would accept any arbitrary content,

  • 0

I need to develop a template-like user control, which would accept any arbitrary content, including other controls.

WmlCard.ascx

<asp:PlaceHolder ID="phContent" runat="server">
<card id="<%= Me.CardId %>" title="<%= Me.Title %>"> 
<p>
    <%= Me.InnerText %>
</p>
</card>
</asp:PlaceHolder>

It would be used this way:
ListaTelefonica.aspx

<%@ Register TagPrefix="sic" TagName="Card" Src="~/path/to/WmlCard.ascx"%>    
<sic:Card ID="BuscaCard" runat="server" CardId="busca" title="Lista Telefônica" Visible="false">
   <asp:Literal ID="SomeLiteral" runat="server" Visible="false">Some text<br /></asp:Literal>
   <asp:Literal ID="RuntimeFilledLiteral" runat="server" Visible="false" /><br /></asp:Literal>
   Any text.
</sic:Card>

It is unfortunate that Ascx user controls have to inherit System.Web.UI.UserControl. If I could inherit System.Web.UI.WebControls.WebControl, for example, it would be a piece of cake.

My problem is similar to this one, but instead of just text the control should accept any other control inside it.


I tried <ParseChildren(False)> and overriding AddParsedSubObject(Object) in WmlCard, but it is not a solution because the html is rendered before the Page Load, making it pointless to change the value of RuntimeFilledLiteral.Text in a page’s Page_Load, for example.

First error I got:
Parser Error Message: Type ‘ASP.sic_sicphone_usercontrol_wmlcard_ascx’ does not have a public property named ‘Literal’.

After adding <PersistenceMode(PersistenceMode.InnerDefaultProperty), ParseChildren(True, "InnerText")>:
The ‘InnerText’ property of ‘sic:Card’ does not allow child objects.

Same as above but changing WmlCard’s property InnerText type from String to List(Of Object):
Literal content (‘Any text.’) is not allowed within a ‘System.Collections.IList’.

After adding <ParseChildren(False)> and overriding AddParsedSubObject:
No error message, but WmlCard’s content is rendered to html before I have a chance to change its inner controls runtime properties.

If I change WmlCard to inherit System.Web.UI.WebControls.PlaceHolder instead of System.Web.UI.UserControl:
‘…UserControl.WmlCard’ is not allowed here because it does not extend class ‘System.Web.UI.UserControl’.

  • 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-20T12:35:40+00:00Added an answer on May 20, 2026 at 12:35 pm

    Found a valid way:

    1) Put nothing inside my control (WmlCard.ascx).

    2) Added the attribute <ParseChildren(False)> to WmlCard.

    3) Added a handler to the event PreRender on WmlCard:

    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
      Dim litBefore As New Literal()
      litBefore.Text = String.Format("<card id=""{0}"" title=""{1}""><p>", Me.CardId, Me.Title)
    
      Dim litAfter As New Literal()
      litAfter.Text = "</p></card>"
    
      Me.Controls.AddAt(0, litBefore)
      Me.Controls.Add(litAfter)
    End Sub
    

    And that’s it. Everything is working. Thanks for your help thinking thru this!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to develop an application which stores data in a SQL Server 2005
I need to develop a CRM system which will allow users to have a
I would like to use the HTML::Template module. However, it is not installed on
I need to develop a software which works for both windows and Mac OS.
I need to develop a system which accepts orders and returns confirmation. Orders could
I want brief knowledge about Data Template for Customizing a control(like Combo Box,List Box
I need to develop a feature in the system which allows unregistered users to
I need to develop a small-medium sized desktop GUI application, preferably with Python as
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application
I need to develop a system for storing large numbers (10's to 100's of

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.