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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:46:06+00:00 2026-05-22T15:46:06+00:00

The title is not entirely accurate, I have a Container control with a property

  • 0

The title is not entirely accurate, I have a Container control with a property of type PanelControlCollection which is basically a collection of PanelControl:

public class PanelControl : System.Web.UI.WebControls.Panel
{
    public string Title { get; set; }
}

public class PanelControlCollection : Collection<PanelControl> {}

My custom User Control:

public partial class FormSlideShow : BaseUserControl
{
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public PanelControlCollection Panels Title { get; set; }

    protected override void Render(HtmlTextWriter writer)
    {
        foreach(var panel in Panels)
        {
            ContentPlaceHolder.Controls.Add(
                new LiteralControl("<fieldset class='step' Title='" + panel.Title + "'>"));
            ContentPlaceHolder.Controls.Add(panel);
            ContentPlaceHolder.Controls.Add(
                new LiteralControl("</fieldset>"));
        }
        base.Render(writer);
    }
}

I wanted to be able to make a custom control and add pages in markup (code in Default.aspx):

<ctrl:FormSlide runat="server" ID="frmSlide">
    <Panels>
        <ctrl:PanelControl runat="server" ID="page1"><asp:Button runat="server" ID="btnTest" OnClick="btnTest_Onclick" /></ctrl:PanelControl>
        <ctrl:PanelControl runat="server" ID="PanelControl1">Page 2</ctrl:PanelControl>
    </Panels>
</ctrl:FormSlide>

My question is, if I want to host the control in a normal aspx page, how can I connect my Button control (btnTest) to the OnClick event in the code behind of default.aspx? If I put a normal Panel control with a button I can attach events to the onclick but not with my custom control.

btw here is my code behind on default.aspx, the code which I want to run but can’t:

protected void btnTest_Onclick(object sender, EventArgs e)
{
    Response.Redirect("http://www.google.com");
}

Thanks.

  • 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-22T15:46:07+00:00Added an answer on May 22, 2026 at 3:46 pm

    Try moving this:

    foreach(var panel in Panels)
    {
        ContentPlaceHolder.Controls.Add(
            new LiteralControl("<fieldset class='step' Title='" + panel.Title + "'>"));
        ContentPlaceHolder.Controls.Add(panel);
        ContentPlaceHolder.Controls.Add(
            new LiteralControl("</fieldset>"));
    }
    base.Render(writer);
    

    into OnInit rather than Render. I think Render is too late to register PostBack events with ASP.NET. I was able to reproduce your issue and then resolve it by moving that piece of code.

    Of course, base.Render(writer); should be replaced with base.OnInit(e);

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

Sidebar

Related Questions

First off, I'm not entirely sure that my question title is very descriptive, so
I am not entirely sure what title to put on this problem to get
I'm not entirely sure the title is properly worded, but here's the situation... I
I'm not sure if my Title for this question entirely describes accurately enough what
I have an html string like this one (this is not the entirely html):
Firstly, apologies for the bad question title - not entirely sure if I am
I'm not entirely sure how to phrase this as a concise question title. I
I think I have entirely to many variables, but I cant exactly not have
Basically what the title says, My application consists primarily of a ViewPager which uses
Pretty clear in the title, I think. I'm not entirely sure on this, and

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.