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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:56:15+00:00 2026-05-23T16:56:15+00:00

I have a custom usercontrol that has some Asp.net code. I would like to

  • 0

I have a custom usercontrol that has some Asp.net code. I would like to write the same code but with C#.
The problem is that i don’t know how to put a repeater and some buttons into the ContentTemplate.

The Asp.net Code :

<asp:UpdatePanel runat="server" ID="up">

    <ContentTemplate>

        <n2:Repeater ID="rpt" runat="server">
            <ItemTemplate></ItemTemplate>
        </n2:Repeater>

         <asp:LinkButton runat="server" ID="btnFirst" 
           Visible="false" Enabled="false" Text="<<" OnClick="btnFirst_Click" />

    </ContentTemplate>

</asp:UpdatePanel>

So how could I write this chunk in C# code? To be precise, how could I insert the repeater and the Linkbutton into the ContentTemplate.

Note : I don’t want to use the LoadTemplate to do it.

Edit

I have tried ContentTemplateContainer.Controls.Add():

    private UpdatePanel up = new UpdatePanel();
    private Repeater rpt = Repeater();;

    public Paging{      

    //Add repeater to updatePanel
    up.ContentTemplateContainer.Controls.Add(rpt);


     AsyncPostBackTrigger apb3 = new AsyncPostBackTrigger();
     apb3.ControlID = "btnFirst";
     apb3.EventName = "Click";

     //Add Triggers to updatePanel
     up.Triggers.Add(apb1);

      //Create buttons
      btnFirst = new LinkButton();
      btnFirst.Visible = false;
      btnFirst.Enabled = false;
      btnFirst.Text = "<<";
      btnFirst.Click += new EventHandler(btnFirst_Click);

     //Add buttons to update panel
       up.ContentTemplateContainer.Controls.Add(btnFirst);

     }

     protected void Page_Load(object sender, EventArgs e)
     {
        rpt.ItemTemplate = LoadTemplate("~/UI/Templates/NewsEvent.ascx");
       ....
     }

I have an error caused by the first line on Page_Load :
Databinding methods such as Eval(), XPath(), and Bind() can only be used in controls contained in a page.

This is NewsEvent.ascx:

<img src='<%# Eval("ImageThumbnail") %>' alt="" />
  • 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-23T16:56:15+00:00Added an answer on May 23, 2026 at 4:56 pm

    you cant do this with ITemplate types … i had a similar problem trying to clone a tabpanel in a tabcontainer control … i already had a hidden tabpanel and all i wanted to do was create a new tabpanel and basically instantiate the ITemplate from the hidden one in the new one.

    The problem is ITemplate … it’s not very dynamic for code behind interactions i would suggest putting that markup on the page as you already have and setting visible = false on the parent then when you need to databind and show the hidden panel.

    getting the initial bind to work isn’t the problem … its the postback handling …

    Ajax TabContainerTabPanels Break postbacks

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

Sidebar

Related Questions

I have an ASP.NET web form that has a container usercontrol that hosts several
I am building in some custom javascript functionality in an existing ASP.NET usercontrol. The
I have a Custom UserControl . In that UserControl i have some buttons ,
I have a custom form that has 4 panels on it edges. I would
I have a custom control that inherits from UserControl , and I can't get
I have a custom user control that contains asp:ValidationSummary . It is placed on
I have a custom UserControl which has a DependencyProperty ItemTemplate of type DataTemplate. I
I have made a custom UserControl i Vb.net (windows application). How can I add
I've got a usercontrol that has a <asp:TextBox> with autopostback set to true. When
I have a custom UserControl that have a StatusStrip. So, I resize this control

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.