开发者

ASP C# User Controls Circular Reference

I have an ASP web project that currently has a reusable usercontrol representing an electronic form. The 'form' control in turn has many different types of 'item' usercontrol on it. There are about a dozen different 'item' usercontrols that extend an 'item' class. The form and its items are po开发者_如何学Cpulated from a database. This works and compiles fine.

What I need to do is to be able to embed another Form Item on one of the item types to create an embedded form. Essentially take the current 'Form1 -> Item 1A, Item 1B, Item 1C' layout and make it circular, so it may look like

Form1 -> 
   Item1A 
   Item 1B-Form2 -> 
         Item2A 
         Item2B 
   Item1C

So an instance of UserControl1 may contain an instance of UserControl2 which will contain an instance of UserControl1.

ASP is giving me the following error "[UserControl2].ascx has a circular reference!".

Is this structure even possible?

Many thanks


Have you try to add controls dynamically by its path?

For example:

WebUserControl1 uc = 
  (WebUserControl1) Page.LoadControl("WebUserControl1.ascx"); 
PlaceHolder1.Controls.Add(uc);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜