HighTechTalks DotNet Forums  

Problem accessing control from inside other control

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Problem accessing control from inside other control in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Nathan Sokalski
 
Posts: n/a

Default Problem accessing control from inside other control - 01-02-2008 , 10:19 PM






I have a validator that I wrote by inheriting from BaseValidator. At certain
points in the code, I need to access other controls on the page containing
the validator. I have the IDs of these controls, so I use the following
statement to access them:

Me.Page.FindControl(ControlID)

However, this is returning Nothing, even though the control can be accessed
in the Load event of the Page containing the control and the validator. I
also want to mention that the Page uses a Master Page, and the control and
validator are declared in the Page, not the Master Page. I am not sure if
this makes a difference or not. Can someone tell me what I am doing wrong?
Thanks.
--
Nathan Sokalski
njsokalski (AT) hotmail (DOT) com
http://www.nathansokalski.com/



Reply With Quote
  #2  
Old   
Dina
 
Posts: n/a

Default Re: Problem accessing control from inside other control - 01-02-2008 , 10:51 PM






On Jan 3, 9:19 am, "Nathan Sokalski" <njsokal... (AT) hotmail (DOT) com> wrote:
Quote:
I have a validator that I wrote by inheriting from BaseValidator. At certain
points in the code, I need to access other controls on the page containing
the validator. I have the IDs of these controls, so I use the following
statement to access them:

Me.Page.FindControl(ControlID)

However, this is returning Nothing, even though the control can be accessed
in the Load event of the Page containing the control and the validator. I
also want to mention that the Page uses a Master Page, and the control and
validator are declared in the Page, not the Master Page. I am not sure if
this makes a difference or not. Can someone tell me what I am doing wrong?
Thanks.
--
Nathan Sokalski
njsokal... (AT) hotmail (DOT) comhttp://www.nathansokalski.com/
Can you please give more details on where u want to access and where u
are already able to access the controls as in the server side or the
client side?

If u are able to access the controls on the server side and have
trouble accessing them from the client side, then the solution is
pretty simple. By default the client IDs of the server controls get
pre-pended with specific values (I've generally observed the value
"CT001_" or something similar). Just run the page and view the html
source to see the client id of the controls in the client scripts. U
can also get the client id of the controls using a property on the
server side.

Hope this helps

Regards, Dina


Reply With Quote
  #3  
Old   
Nathan Sokalski
 
Posts: n/a

Default Re: Problem accessing control from inside other control - 01-02-2008 , 11:42 PM



As I mentioned in my original post, I am able to access the control in the
Load event of the Page. The place where I want to and am not able to access
it is in the EvaluateIsValid() function of my validator. In the
EvaluateIsValid() function I am attempting to access it using the following:

Me.Page.FindControl(ControlID)

Because the Load event of the Page occurs before the EvaluateIsValid()
function is called, this shows that the control does exist in the page when
I try to access it. Is there something else I need to do when accessing the
control from inside EvaluateIsValid()? Thanks.
--
Nathan Sokalski
njsokalski (AT) hotmail (DOT) com
http://www.nathansokalski.com/

"Dina" <dina.mrcool (AT) gmail (DOT) com> wrote

Quote:
On Jan 3, 9:19 am, "Nathan Sokalski" <njsokal... (AT) hotmail (DOT) com> wrote:
I have a validator that I wrote by inheriting from BaseValidator. At
certain
points in the code, I need to access other controls on the page
containing
the validator. I have the IDs of these controls, so I use the following
statement to access them:

Me.Page.FindControl(ControlID)

However, this is returning Nothing, even though the control can be
accessed
in the Load event of the Page containing the control and the validator. I
also want to mention that the Page uses a Master Page, and the control
and
validator are declared in the Page, not the Master Page. I am not sure if
this makes a difference or not. Can someone tell me what I am doing
wrong?
Thanks.
--
Nathan Sokalski
njsokal... (AT) hotmail (DOT) comhttp://www.nathansokalski.com/

Can you please give more details on where u want to access and where u
are already able to access the controls as in the server side or the
client side?

If u are able to access the controls on the server side and have
trouble accessing them from the client side, then the solution is
pretty simple. By default the client IDs of the server controls get
pre-pended with specific values (I've generally observed the value
"CT001_" or something similar). Just run the page and view the html
source to see the client id of the controls in the client scripts. U
can also get the client id of the controls using a property on the
server side.

Hope this helps

Regards, Dina



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.