Is it possible to 'DataBind' a single property of a user control?

Before I get to the question, let me give a bit of background. I'm trying to develop a custom caching mechanism that I can apply to custom built user controls. (Please be aware that I know that there are some built in caching mechanism in .NET) Depending on certain flags set declaratively in the mark-up the control should load a cached version of its previously rendered content or execute normally (and if certain flags are set it should generate a cache of its content for next time it loads). I would like to be able to pass certain flags declaratively in the mark-up and being able to check their value at Page Init and, depending on the flag value, determine whether the control should load a cached version or not.

<uc:MyUC ID="N1" runat="server"
   CacheProp='<%# SomeEnum.A | SomeEnum.B |SomeEnum.C %>'
   PropA='<%# this.SomePropA %>' 
   PropB='<%# (this.SomePropB %>'
   PropC='<%# this.SomePropC %>'
/>

The problem that I'm facing is that as far as I'm aware I can only get the value of the properties declaratively assigned in the mark-up if I called the DataBind(). However I'm faced with two problems: Firstly calling this.DataBind() from within MyUC will trigger the binding of all its child controls which would defeat the purpose of the cache; also all user controls have been built so that they will not call DataBind() before the LoadComplete event has fired, so to make sure that the parent controls they live in has done its initialisation and has computed the properties that are declaratively passed to the child user control (ie PropA, PropB, PropC).

And now the question: is there a way to bind the CacheProp property so to retrieve its value without data binding all other properties and without triggering the data binding of all its child controls?

Thanks for helping!

Giuseppe

Answers


This should work:

<uc:MyUC ID="N1" runat="server" CacheProp="A|B|C"... >

Code behind:

strRawValue = N1.Attributes["CacheProp"];
string[] arrValues = strRawValue.Split('|');
SomeEnum value = (SomeEnum)Enum.Parse(typeof(SomeEnum), arrValues[0]);
for (int i = 1; i < arrValues.Length; i++)
    value |= (SomeEnum)Enum.Parse(typeof(SomeEnum), arrValues[i]);

Need Your Help

Message: Undefined index: image

php codeigniter file-upload

I am trying to implement a post functionality and want to pick message and image from a php view. I am receiving an error Message: Undefined index: image although i have defined it in my view. this...

creating a results page in django

django forms

I am creating my first web app and am trying to understand how to write a page which shows the results of a submitted form and would like some guidance on how to do this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.