Content is not allowed between the opening and closing tags for user control

后端 未结 6 1726
你的背包
你的背包 2020-12-16 15:47

I want to build a user control suppose MyDiv.ascx. This control renders the div tag and do few more code behind stuff like adding few attributes etc which is not a matter of

6条回答
  •  一生所求
    2020-12-16 16:26

    I believe you just need to apply a couple of attributes to the control:

    [ParseChildren(false)]
    [PersistChildren(true)]
    public class MyDiv : UserControl
    {
        ...
    

    You may then need to override AddedControl - I'm not sure.

    Put it this way - that's what works for the one and only user control I've ever written :)

提交回复
热议问题