HTML in custom control lost when property changed in design view

Discussion in 'ASP .Net Web Controls' started by Christopher Strolia-Davis, Dec 6, 2004.

  1. 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?
    Christopher Strolia-Davis, Dec 6, 2004
    #1
    1. Advertising

  2. Christopher Strolia-Davis

    aa7im Guest

    aa7im, Dec 6, 2004
    #2
    1. Advertising

  3. Christopher Strolia-Davis

    aa7im Guest

    aa7im, Dec 6, 2004
    #3
  4. Christopher Strolia-Davis

    aa7im Guest

    aa7im, Dec 6, 2004
    #4
  5. Christopher Strolia-Davis, Dec 6, 2004
    #5
  6. Re: HTML in custom control lost when property changed in design vi

    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.

    "Christopher Strolia-Davis" wrote:

    > Tried setting the persistChildrenAttribute both to true and then to false and
    > neither of these modifications seems to change the outcome.
    >
    Christopher Strolia-Davis, Dec 6, 2004
    #6
  7. 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

    "Christopher Strolia-Davis" wrote:

    > 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.
    >
    Christopher Strolia-Davis, Dec 7, 2004
    #7
  8. RE: HTML in custom control lost when property changed in design vi

    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.

    "Christopher Strolia-Davis" wrote:

    > 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)>
    >
    Christopher Strolia-Davis, Dec 7, 2004
    #8
  9. 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.

    "Christopher Strolia-Davis" wrote:

    > 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?
    >
    >
    Christopher Strolia-Davis, Dec 7, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    1
    Views:
    592
    VB Programmer
    Jul 10, 2003
  2. Rolf Welskes
    Replies:
    3
    Views:
    456
    Rolf Welskes
    Oct 6, 2006
  3. Don
    Replies:
    0
    Views:
    151
  4. Ziyad Makki
    Replies:
    1
    Views:
    357
    Harry F. Harrison
    Aug 23, 2004
  5. Don
    Replies:
    0
    Views:
    140
Loading...

Share This Page