Finding object from ID

S

Søren Reinke

Hi there

I am trying to create the following server control.

My control has 3 stages, where it show 1 of 3 images, as parameter is gets
1-3 ID's of validators on the aspx page.

States:
1. No required validators, show an empty image
2. One or more validator was invalid, show a red arrow image
3. All validators are valid show green arrow image.

(the control just returns '<img src="red.gif" />'

My problem is, in the aspx page i have:
<cc1:ValidationPicture ID="ValidationPicture1" runat="server"
Validator1="cityRequiredFieldValidator"
Validator2="cityRegularExpressionValidator"/>

My method in the DLL get's called correctly, but how do i get from the ID af
a validator 'cityRegularExpressionValidator' to the object ? So i can call
'isValid()' on it ?

I tried with:

obj=Page.FindControl(ID)

and

obj=FindControl(ID)

Put the first one fails because 'Page' is null/nothing the other one always
returns null/nothing.

I have tried to google it, but no luck :( How do the validators do it ? The
also just get an ID and evaluate the objects content.

Please help me, an example would be nice, if does not matter if it is in VB
or C#

--
Best regards C.T.O. Søren Reinke
www.Xray-Mag.com/ - Your free diving magazin on the net. Download it in PDF
BALI :: Polluce Wreck: A tale of treasures lost and found. SALT
(mini-theme):
The Salty Oceans - Survive on Seawater? - Mangroves
 
S

Søren Reinke

Peter Blum said:
Hi Søren,

The FindControl method searches only controls in the same "naming
container" of the object that method is called on. If you call
Page.FindControl, it searches the Page naming container, but nothing it
contains that implements INamingContainer, like a UserControl or row of a
DataGrid. It sounds like your validators are in different naming
containers.

Thanks for the tips :)

What i actually was doing was that i tried to get to the Page object before
it existed (in the get/set methods), of course i should do it in the render
method instead and now it works.

--
Best regards C.T.O. Søren Reinke
www.Xray-Mag.com/ - Your free diving magazin on the net. Download it in PDF
BALI :: Polluce Wreck: A tale of treasures lost and found. SALT
(mini-theme):
The Salty Oceans - Survive on Seawater? - Mangroves
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top