You aren't doing anything wrong. User controls that you create in ascx
file are different than custom controls that you drag in from the tool
box. You can see this in the way the designer displays the gray blob
for user controls as compared to the rendered output of the custom
controls. You do have to add the declaration yourself in order to
access the user control from codebehind. It is a pain in the back side
but it seems to be the way it is.
Have A Better One!
John M Deal, MCP
Necessity Software
Bennett Haselton wrote:
> I create a new Web Form and drag a new Button onto it from the Web
> Forms toolbox tab, and then I drag a new instance of the UserPost user
> control that I created, by dragging and dropping the "UserPost.ascx"
> file listing from Solution Explorer. Both controls show up on the Web
> Form. But when I switch to the codebehind page, there is only a
> declaration for Button1:
>
> protected System.Web.UI.WebControls.Button Button1;
>
> and not one for UserPost1. Is this a bug? A feature? I'm not too
> lazy to type the declaration in myself, but anomalies like this are
> sometimes a sign that I'm doing something wrong...
>
> -Bennett
|