Note that there are some explanatory texts on larger screens.

plurals
  1. POButton in Panel not calling Parent Onclick Event
    primarykey
    data
    text
    <p>The title is not entirely accurate, I have a Container control with a property of type <code>PanelControlCollection</code> which is basically a collection of <code>PanelControl</code>:</p> <pre><code>public class PanelControl : System.Web.UI.WebControls.Panel { public string Title { get; set; } } public class PanelControlCollection : Collection&lt;PanelControl&gt; {} </code></pre> <p>My custom User Control:</p> <pre><code>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("&lt;fieldset class='step' Title='" + panel.Title + "'&gt;")); ContentPlaceHolder.Controls.Add(panel); ContentPlaceHolder.Controls.Add( new LiteralControl("&lt;/fieldset&gt;")); } base.Render(writer); } } </code></pre> <p>I wanted to be able to make a custom control and add pages in markup (code in Default.aspx):</p> <pre><code>&lt;ctrl:FormSlide runat="server" ID="frmSlide"&gt; &lt;Panels&gt; &lt;ctrl:PanelControl runat="server" ID="page1"&gt;&lt;asp:Button runat="server" ID="btnTest" OnClick="btnTest_Onclick" /&gt;&lt;/ctrl:PanelControl&gt; &lt;ctrl:PanelControl runat="server" ID="PanelControl1"&gt;Page 2&lt;/ctrl:PanelControl&gt; &lt;/Panels&gt; &lt;/ctrl:FormSlide&gt; </code></pre> <p>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.</p> <p>btw here is my code behind on default.aspx, the code which I want to run but can't:</p> <pre><code>protected void btnTest_Onclick(object sender, EventArgs e) { Response.Redirect("http://www.google.com"); } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload