Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Custom Controls- Controls Collection-FindControl method (http://www.velocityreviews.com/forums/t775573-custom-controls-controls-collection-findcontrol-method.html)

Sundararajan 03-08-2005 09:09 AM

Custom Controls- Controls Collection-FindControl method
 
Hi folks,

I have some 10 LinkButton controls by the name
lnkbtnPage1,lnkbtnPage2...lnkbtnPage10.
I manipulate the visibility of these controls by

for(intLoop=1; intLoop<GROUPPAGESIZE;intLoop++)
{
((LinkButton)(FindControl("lnkbtnPage"+intLoop))). Visible=false;
}

This works fine in user controls.
But i want to do the same operation in Custom controls there this
FindControl does not work and it throws the error object reference not set to
an instance of the object.

I am doing this after adding the link buttons to the Controls collection in
CreateChildControls method.

Is there any work around.
--
S.Sundararajan

quaester 03-09-2005 11:33 AM

RE: Custom Controls- Controls Collection-FindControl method
 
you have to put your codes in the last few events of the control, in my case
it works when i put it in the PreRender event handler.

Reason being is that your controls classes is not loaded yet!

Take me some time to figure out though, hofully yours is the same issue.

"Sundararajan" wrote:

> Hi folks,
>
> I have some 10 LinkButton controls by the name
> lnkbtnPage1,lnkbtnPage2...lnkbtnPage10.
> I manipulate the visibility of these controls by
>
> for(intLoop=1; intLoop<GROUPPAGESIZE;intLoop++)
> {
> ((LinkButton)(FindControl("lnkbtnPage"+intLoop))). Visible=false;
> }
>
> This works fine in user controls.
> But i want to do the same operation in Custom controls there this
> FindControl does not work and it throws the error object reference not set to
> an instance of the object.
>
> I am doing this after adding the link buttons to the Controls collection in
> CreateChildControls method.
>
> Is there any work around.
> --
> S.Sundararajan


Sundararajan 03-10-2005 06:13 AM

RE: Custom Controls- Controls Collection-FindControl method
 
However as i am adding the controls in the CreateChildControls() method of
the control class is that possible to voverride the prerender method.

"quaester" wrote:

> you have to put your codes in the last few events of the control, in my case
> it works when i put it in the PreRender event handler.
>
> Reason being is that your controls classes is not loaded yet!
>
> Take me some time to figure out though, hofully yours is the same issue.
>
> "Sundararajan" wrote:
>
> > Hi folks,
> >
> > I have some 10 LinkButton controls by the name
> > lnkbtnPage1,lnkbtnPage2...lnkbtnPage10.
> > I manipulate the visibility of these controls by
> >
> > for(intLoop=1; intLoop<GROUPPAGESIZE;intLoop++)
> > {
> > ((LinkButton)(FindControl("lnkbtnPage"+intLoop))). Visible=false;
> > }
> >
> > This works fine in user controls.
> > But i want to do the same operation in Custom controls there this
> > FindControl does not work and it throws the error object reference not set to
> > an instance of the object.
> >
> > I am doing this after adding the link buttons to the Controls collection in
> > CreateChildControls method.
> >
> > Is there any work around.
> > --
> > S.Sundararajan



All times are GMT. The time now is 03:58 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.