开发者

Custom ASP binding mechanism problem

know ASP since about 6 months, and I've go hard problem. I've created my own DataBinding mechanism and I need some solution to do somthing like this:

I have this example code in my ASPX

<myButton id="someID" runat="server" Text="SomeText" BackColor="{SomeContext}" />

and I have in this control my property Context of type Object. I want to bind property which is inside Context to BackColor property. Name of the property from Context is SomeContext (in brackets). All I need is to use some TypeConverter or other technology to identify that there is a name inside {} and remember that name insid开发者_运维知识库e instance of myButton control. Any ideas???

I thought that I can use my own class inherited from TypeConverter and catch the moment of converting value {SomeContext} to Color (the BackColor property). I can catch this moment, but I have no info about target control, only empty context of String value. If anyone know how to get target property somehow, will be very!! helpful.

I've been searching web, and nothing...


You can set this in your code behind directly:

someID.BackColor = context.Color;


Ya might give ASP.NET Custom Expression builders a try.


I won't use codebehind in my project. Website will be rendered from compiled customized aspx from database. I have special approach for my system, and my binding is a main part of it. Regular databinding expression won't help because it use ASP binding, which I don't want to use.


Unfortunately I didn't find any solution of my problem, so I decided to use inner properties. I'll use ASPX code like this:

<myButton runat="server" ID="someID">
    <Binding>
       <Bind Target="BackColor" Source="ColorOfBackgroundFromContext" />
       <Bind Target="ForColor" Source="ColorOfForegroundFromContext" />
    </Binding>  
</myButton>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜