I am using an ASP.Net Web Application project. I have a user control which has an asp.net button in it. When i use that user control on the page, the button does not appear, but if i put the button directly on the page, the buttons shows up. Any idea what the problem is?
Also, inside that user control, i can override the render method and the test passed to the render method works, but I still do not get a button
The assembly is registered in the web.config
EDIT:After dave's post, i found that anything put in the .ascx file does not work, while overriding that user control's render method works
The Page
<%@ Page Title="Home" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Site.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<uc:SomeCustomControl ID="myControl" runat="server" />
<asp:Button runat="server" Text="outControl" />
</div>
</asp:Content>
the control .ascx file
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="Site.Controls.TestControl" %>
<asp:Button runat="server" Text="InControl" /><!--cant see this button-->
<p>I can't see this</p><!--cant see this text-->
the code behind for the .ascx file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Site.Controls
{
public partial class TestControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("I can see this");
base.Render(writer);
}
}
}
And the page source
I can see this
<input type="submit" name="ctl00$ContentPlaceHolder1$Button1" value="outControl" id="ctl00_ContentPlaceHolder1_Button1" />