Finding object from ID

Discussion in 'ASP .Net Web Controls' started by Søren Reinke, Oct 10, 2005.

  1. 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øren Reinke, Oct 10, 2005
    #1
    1. Advertising

  2. "Peter Blum" <> wrote in message
    news:...
    > 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
     
    Søren Reinke, Oct 11, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl
    Replies:
    0
    Views:
    469
  2. George Smith
    Replies:
    1
    Views:
    329
    Andrew Thompson
    Feb 24, 2004
  3. Replies:
    4
    Views:
    356
    Roedy Green
    Nov 24, 2005
  4. bmatt

    Finding a python object in c++

    bmatt, Sep 17, 2004, in forum: Python
    Replies:
    3
    Views:
    346
    Alex Martelli
    Sep 17, 2004
  5. Derek Peschel
    Replies:
    6
    Views:
    304
    Fredrik Lundh
    Aug 26, 2006
Loading...

Share This Page