HTML in custom control lost when property changed in design view

  • Thread starter Christopher Strolia-Davis
  • Start date
C

Christopher Strolia-Davis

I've searched in vain to find the answer to this question, so hopefully
someone can help me.

I am creating a web custom control that will have other nested content. I
have set parseChildren attribute to false, so I can embed the content in my
finished output. When the control has been placed in my page, if I go to
design view and change a property, when I move back to HTML view, all content
between the opening and closing tags is removed.

for instance, if I have code like:

<mc:MyControl MyAttribute='Something'>
<ul>
<li>some text</li>
</ul>
</mc:MyControl>

if I go to design view and change "MyAttribute" to "Something Else" and
return to
HTML view I get

<mc:MyControl MyAttribute='Something Else'>
</mc:MyControl>

All the code inside the control is lost.

Is there some sort of property or setting that I need to change to make sure
that this doesn't happen?
 
C

Christopher Strolia-Davis

Tried setting the persistChildrenAttribute both to true and then to false and
neither of these modifications seems to change the outcome.
 
C

Christopher Strolia-Davis

Okay,

I think I'm getting close to an answer now. It seems as if I need to make a
controlbuilder for the inner content of the control (or something like that).
I still have to work out the details.

I also found that if I set parseChildren to true, I can also specify a
default property for content that is not a property value equivalent.

If someone knows I'm on the wrong track, I'd appreciate it if you can let me
know asap so I don't end up spinning my wheels for nothing.
 
C

Christopher Strolia-Davis

Okay,

I've found the(an) answer to my issue, and am posting it here in case it
helps anybody.

If I create a string property in the webcontrol and set the following
meta-data for it:
<PersistenceMode(PersistenceMode.InnerDefaultProperty)>

it seems to hold on to the inside content.

Later,

Chris
 
C

Christopher Strolia-Davis

My Bad,

Apparently I only thought this was the answer because I tested it incorrectly.

I'm still having the problem.

If anyone knows the "real" answer to the problem, please let me know.
 
C

Christopher Strolia-Davis

I don't know if this is the best answer, but it worked.

I found that if I simply inherit from the system.web.ui.webcontrols.panel
control, which has much of the core functionality I was already looking for,
I was able to get past this issue. (How the panel control handles this issue,
I have no idea).

Just thought I'd let everyone know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top