[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Re: How to access web control from code behind page?

Saravana [MVP]

6/28/2004 5:36:00 AM

You shouldnt declare that component as system.web.ui.usercontrol in
codebehind, instead you should declare that component as your usercontrol
like <Usercontrolnamespace>.<usercontrolclassname>. So that you can access
your usercontrol properties inside codebehind

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



"William Parker" <wilpark@nonospam.com> wrote in message
news:44OdnaCtn__950LdRVn-uw@comcast.com...
> Thanks Dale, but how *exactly* do I go about doing that?
>
> For example in my original post I said this:
> "If I add a declaration above Page_Load in the code behind like this
> "protected System.Web.UI.UserControl Header1;" then the above error goes
> away, but then it complains that Header1 doesn't contain a definition for
> "Title". This is because by declaring Header1 in the web form code behind
> it is obviously just creating it as a new, blank web control when in fact
I
> am just looking for a way to reference the one that is created in the
.aspx
> file. So obviously this is the wrong approach, but the right idea?"
>
> Anyway I am confused how exactly I am support to add a declaration for the
> contorl in the code behind which references the user control created in
the
> .aspx with:
> <%@ Register TagPrefix="uc1" TagName="header" Src="header.ascx" %>
> <uc1:header Title="This is working!!" id="Header1"
>
> Can you please advise? Thanks!
>
>
> "DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
> news:OTPBL5HXEHA.808@tk2msftngp13.phx.gbl...
> > Make sure you add a declaration for the control in your code-behind
class.
> >
> > Dale
> >
>
>
>