check validity of a controls property at compile time

Discussion in 'ASP .Net Building Controls' started by Merrycoder, Apr 17, 2008.

  1. Merrycoder

    Merrycoder Guest

    I'm trying to check the validity of a server controls property at compile
    time. Let's say I have my control embedded in a page like so:

    <cc1:MyControl ID="MyControl1" TheObject="<%# oPerson %>"
    PropertyName="FirstName" runat="server" />

    The control's property references the page level object instance oPerson.
    What I would like to do is to find out the type of the field 'oPerson' and if
    it has a property 'FirstName'. If not, compilation should fail. I have been
    playing around with a custom ControlBuilder but with no success.

    Does anyone have a solution? My eternal gratefulness would be yours :)

    Merrycoder, Apr 17, 2008
    1. Advertisements

  2. Hello Stefan
    There is AFAIK no way to do that with out-of-the-box solutions.
    As you assumed, it will only work, if you compile the whole thing like the
    Engine does, because of the templating / databinding stuff itself is located
    on this layer (Compilation-Layer).
    Peter Bucher [MVP], May 1, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.