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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:09:29+00:00 2026-05-24T07:09:29+00:00

The following codes are simplified. The user-control ascx: <%@ Control Language=C# AutoEventWireup=true CodeBehind=BaseFormControl.ascx.cs Inherits=SOPR.CustomForms.BaseFormControl

  • 0

The following codes are simplified.

The user-control ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="BaseFormControl.ascx.cs"
    Inherits="SOPR.CustomForms.BaseFormControl" %>
<fieldset class="fset1">
</fieldset>

This is my user control code-behind:

public partial class BaseFormControl : System.Web.UI.UserControl
    {



        [TemplateContainer(typeof(ContentContainer))]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ITemplate Content { get; set; }



   void Page_Init()
        {




            if (Content != null)
            {
                ContentContainer cc = new ContentContainer();
                Content.InstantiateIn(cc);
                contentHolder.Controls.Add(cc);
            }
        }

My usage in the view:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddOperator.aspx.cs"
    Inherits="SOPR.Cadastro.AddOperator" MasterPageFile="~/MasterPage.Master" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="maincont" runat="server"     EnableViewState="true">
    <uc:BaseFormControl ID="BaseFormControl1" runat="server">
        <Content>
      <asp:TextBox runat="server" CssClass="keytbcss" MaxLength="4" ID="keytb"
                NewLine="false" />
        </Content>
    </uc:BaseFormControl>

I’m trying to access the “keytb” control on the code-behind, but its like it didnt exist (like using a variable that doesn’t exist). Any ideas?

Thanks in advance.

SOLUTION ————————–
I found a quite nice solution, just add [TemplateInstance(TemplateInstance.Single)] to the ITemplate property of the user control and everything gets seen. I can now use just like it was a normal page control.

public partial class BaseFormControl : System.Web.UI.UserControl
{



[TemplateContainer(typeof(ContentContainer))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateInstance(TemplateInstance.Single)]
public ITemplate Content { get; set; }
...
  • 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-24T07:09:30+00:00Added an answer on May 24, 2026 at 7:09 am

    SOLUTION ————————–
    I found a quite nice solution, just add [TemplateInstance(TemplateInstance.Single)] to the ITemplate property of the user control and everything gets seen. I can now use just like it was a normal page control.

    public partial class BaseFormControl : System.Web.UI.UserControl
    {
    
    
    
    [TemplateContainer(typeof(ContentContainer))]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [TemplateInstance(TemplateInstance.Single)]
    public ITemplate Content { get; set; }
    ...
    
    • 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 with the following XAML: <ScrollViewer> <ListBox ItemsSource={Binding Items}> <ListBox.ItemTemplate>
So the problem is the following : i do have own user control. which
Imagine I have the following code (simplified regarding my real context of course): <div
I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE>
The following code is a simplified version of what I use for event dispatching.
I am debugging some code and have encountered the following SQL query (simplified version):
I run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests
I can use the following codes to trim a string: -(void) aMethod { //
When I compiled the sample codes of C++, I got following info: c++ excxx_example_database_read.cpp
I'm writing code to present the user with a simplified network map. At any

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.