all groups > asp.net building controls > april 2008 >
You're in the

asp.net building controls

group:

check validity of a controls property at compile time


check validity of a controls property at compile time Merrycoder
4/17/2008 4:51:01 AM
asp.net building controls: 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
Re: check validity of a controls property at compile time Peter Bucher [MVP]
5/1/2008 4:53:39 PM
Hello Stefan

[quoted text, click to view]
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
AddThis Social Bookmark Button