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 :)

    Regards
    Stefan
    Merrycoder, Apr 17, 2008
    #1
    1. Advertising

  2. Hello Stefan

    > 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.

    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
    ASP.NET
    Engine does, because of the templating / databinding stuff itself is located
    on this layer (Compilation-Layer).

    --
    Gruss, Peter Bucher
    Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
    http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
    http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
    Peter Bucher [MVP], May 1, 2008
    #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. Martin Burger
    Replies:
    3
    Views:
    545
    Roland
    Jun 30, 2005
  2. Rex_chaos
    Replies:
    3
    Views:
    318
    tom_usenet
    Oct 28, 2003
  3. shuisheng
    Replies:
    2
    Views:
    322
    Jerry Coffin
    Feb 16, 2007
  4. Carter
    Replies:
    2
    Views:
    488
    Carter
    Mar 4, 2009
  5. Igor Korot

    How to check the date validity?

    Igor Korot, Dec 24, 2013, in forum: Python
    Replies:
    1
    Views:
    85
    gregor
    Dec 24, 2013
Loading...

Share This Page