开发者

Coupling between (web)controls in ASP.NET 4

I was wondering is there is possible to couple together two web controls (ascx) so they would react on each other changes. I have in mind scenario similar to validation controls, where (in validation control) I select available control to be validated.

Now I 开发者_如何学JAVAwould like to do same in my web controls. I have control A and control B. Scenario is that when I change something in control A, control B will be updated. Iam creating controls A and B as WebControls (ascx). I would like (on design time) put two controls (A and B) on webform, and select in control A coupling with control B, so when some event occurs in control A, control A checks if control B is not null and "does things to it".

Is this applicable for WebControl type controls ?! I assume that I should use some attributes on properties of control A, but where to store control B in control A ?! ViewState and Context.Items require controls to be serializable...

Any ideas ?!


You can pass the control id from one control to another. Then you can force the coupled controls to inherit some base class and use FindControl to get an instance of each other. I believe this is how databound controls work with the DataSource controls.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜