RE: Custom ContentPlaceHolder

Discussion in 'ASP .Net' started by Allen Chen [MSFT], Jun 22, 2009.

  1. Hi Gerry,

    >I looked throught the associated control/designer/builder classes in
    >relector but didn't see anything that looked like the culprit.
    >One thing I couldn't find was the MasterPageWebFormDesigner which

    according
    >the MasterPage metadata in vs is supposed to be in
    >Microsoft.VisualStudio.Web.dll.
    >Either this class does not exist in this dll or reflector doesn't see it

    for
    >some reason.


    This exception is exactly thrown by MasterPageWebFormDesigner. So I think
    it's by design and we cannot do anything to eliminate it. You can submit a
    feedback on the connect site to inform our develop team. Our dedicated
    engineers will evaluate your feedback and decide whether to improve it in
    the future.

    https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?
    FeedbackFormConfigurationID=3471&FeedbackType=2

    If you want to look into details, please use reflector to view the code in
    Microsoft.VisualStudio.Web.dll. You can download the assembly from:

    http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/Microsoft.Vis
    ualStudio.Web.dll


    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Allen Chen [MSFT], Jun 22, 2009
    #1
    1. Advertising

  2. Has any progress been made on this issue? I am having the same problem and
    wondered if it has been addressed or if someone has found a workaround?

    "Allen Chen [MSFT]" wrote:

    > Hi Gerry,
    >
    > >I looked throught the associated control/designer/builder classes in
    > >relector but didn't see anything that looked like the culprit.
    > >One thing I couldn't find was the MasterPageWebFormDesigner which

    > according
    > >the MasterPage metadata in vs is supposed to be in
    > >Microsoft.VisualStudio.Web.dll.
    > >Either this class does not exist in this dll or reflector doesn't see it

    > for
    > >some reason.

    >
    > This exception is exactly thrown by MasterPageWebFormDesigner. So I think
    > it's by design and we cannot do anything to eliminate it. You can submit a
    > feedback on the connect site to inform our develop team. Our dedicated
    > engineers will evaluate your feedback and decide whether to improve it in
    > the future.
    >
    > https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?
    > FeedbackFormConfigurationID=3471&FeedbackType=2
    >
    > If you want to look into details, please use reflector to view the code in
    > Microsoft.VisualStudio.Web.dll. You can download the assembly from:
    >
    > http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/Microsoft.Vis
    > ualStudio.Web.dll
    >
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 2 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions. Issues of this
    > nature are best handled working with a dedicated Microsoft Support Engineer
    > by contacting Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    >
    fruitbatinshades, Jun 23, 2009
    #2
    1. Advertising

  3. Hi,

    I believe there's no way to workaround this issue. It's a pure designer
    issue that is caused by MasterPageWebFormDesigner. You can submit your
    feedback in the connect site:

    https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?
    FeedbackFormConfigurationID=3471&FeedbackType=2

    Our product team engineers will evaluate your feedback to see if we can
    improve this in the future edition of Visual Studio.

    Regards,
    Allen Chen
    Microsoft Online Support
    Allen Chen [MSFT], Jun 24, 2009
    #3
  4. Allen Chen [MSFT]

    gerry Guest

    Sounds like we are SOL on this one due to some 'by design' bug in the
    designer.
    My guess is that the master page designer was created by an entry level
    summer intern who never saw any reason for anyone to ever derive a custom
    placeholder and accordingly they made sure that you couldn't.



    "fruitbatinshades" <> wrote in
    message news:...
    > Has any progress been made on this issue? I am having the same problem and
    > wondered if it has been addressed or if someone has found a workaround?
    >
    > "Allen Chen [MSFT]" wrote:
    >
    >> Hi Gerry,
    >>
    >> >I looked throught the associated control/designer/builder classes in
    >> >relector but didn't see anything that looked like the culprit.
    >> >One thing I couldn't find was the MasterPageWebFormDesigner which

    >> according
    >> >the MasterPage metadata in vs is supposed to be in
    >> >Microsoft.VisualStudio.Web.dll.
    >> >Either this class does not exist in this dll or reflector doesn't see it

    >> for
    >> >some reason.

    >>
    >> This exception is exactly thrown by MasterPageWebFormDesigner. So I think
    >> it's by design and we cannot do anything to eliminate it. You can submit
    >> a
    >> feedback on the connect site to inform our develop team. Our dedicated
    >> engineers will evaluate your feedback and decide whether to improve it in
    >> the future.
    >>
    >> https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?
    >> FeedbackFormConfigurationID=3471&FeedbackType=2
    >>
    >> If you want to look into details, please use reflector to view the code
    >> in
    >> Microsoft.VisualStudio.Web.dll. You can download the assembly from:
    >>
    >> http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/Microsoft.Vis
    >> ualStudio.Web.dll
    >>
    >>
    >> Regards,
    >> Allen Chen
    >> Microsoft Online Support
    >>
    >> Delighting our customers is our #1 priority. We welcome your comments and
    >> suggestions about how we can improve the support we provide to you.
    >> Please
    >> feel free to let my manager know what you think of the level of service
    >> provided. You can send feedback directly to my manager at:
    >> .
    >>
    >> ==================================================
    >> Get notification to my posts through email? Please refer to
    >> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >>
    >> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    >> where an initial response from the community or a Microsoft Support
    >> Engineer within 2 business day is acceptable. Please note that each
    >> follow
    >> up response may take approximately 2 business days as the support
    >> professional working with you may need further investigation to reach the
    >> most efficient resolution. The offering is not appropriate for situations
    >> that require urgent, real-time or phone-based interactions. Issues of
    >> this
    >> nature are best handled working with a dedicated Microsoft Support
    >> Engineer
    >> by contacting Microsoft Customer Support Services (CSS) at
    >> http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    >> ==================================================
    >> This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >>
    >>
    >>
    >>
    gerry, Jun 24, 2009
    #4
  5. Allen Chen [MSFT]

    gerry Guest

    for anyone interested :

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=469940


    "gerry" <> wrote in message
    news:%...
    > Sounds like we are SOL on this one due to some 'by design' bug in the
    > designer.
    > My guess is that the master page designer was created by an entry level
    > summer intern who never saw any reason for anyone to ever derive a custom
    > placeholder and accordingly they made sure that you couldn't.
    >
    >
    >
    > "fruitbatinshades" <> wrote in
    > message news:...
    >> Has any progress been made on this issue? I am having the same problem
    >> and
    >> wondered if it has been addressed or if someone has found a workaround?
    >>
    >> "Allen Chen [MSFT]" wrote:
    >>
    >>> Hi Gerry,
    >>>
    >>> >I looked throught the associated control/designer/builder classes in
    >>> >relector but didn't see anything that looked like the culprit.
    >>> >One thing I couldn't find was the MasterPageWebFormDesigner which
    >>> according
    >>> >the MasterPage metadata in vs is supposed to be in
    >>> >Microsoft.VisualStudio.Web.dll.
    >>> >Either this class does not exist in this dll or reflector doesn't see
    >>> >it
    >>> for
    >>> >some reason.
    >>>
    >>> This exception is exactly thrown by MasterPageWebFormDesigner. So I
    >>> think
    >>> it's by design and we cannot do anything to eliminate it. You can submit
    >>> a
    >>> feedback on the connect site to inform our develop team. Our dedicated
    >>> engineers will evaluate your feedback and decide whether to improve it
    >>> in
    >>> the future.
    >>>
    >>> https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?
    >>> FeedbackFormConfigurationID=3471&FeedbackType=2
    >>>
    >>> If you want to look into details, please use reflector to view the code
    >>> in
    >>> Microsoft.VisualStudio.Web.dll. You can download the assembly from:
    >>>
    >>> http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/Microsoft.Vis
    >>> ualStudio.Web.dll
    >>>
    >>>
    >>> Regards,
    >>> Allen Chen
    >>> Microsoft Online Support
    >>>
    >>> Delighting our customers is our #1 priority. We welcome your comments
    >>> and
    >>> suggestions about how we can improve the support we provide to you.
    >>> Please
    >>> feel free to let my manager know what you think of the level of service
    >>> provided. You can send feedback directly to my manager at:
    >>> .
    >>>
    >>> ==================================================
    >>> Get notification to my posts through email? Please refer to
    >>> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >>>
    >>> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    >>> where an initial response from the community or a Microsoft Support
    >>> Engineer within 2 business day is acceptable. Please note that each
    >>> follow
    >>> up response may take approximately 2 business days as the support
    >>> professional working with you may need further investigation to reach
    >>> the
    >>> most efficient resolution. The offering is not appropriate for
    >>> situations
    >>> that require urgent, real-time or phone-based interactions. Issues of
    >>> this
    >>> nature are best handled working with a dedicated Microsoft Support
    >>> Engineer
    >>> by contacting Microsoft Customer Support Services (CSS) at
    >>> http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    >>> ==================================================
    >>> This posting is provided "AS IS" with no warranties, and confers no
    >>> rights.
    >>>
    >>>
    >>>
    >>>

    >
    >
    gerry, Jun 24, 2009
    #5
  6. On Wed, 24 Jun 2009 12:03:47 -0400, "gerry" <>
    wrote:

    >Sounds like we are SOL on this one due to some 'by design' bug in the
    >designer.
    >My guess is that the master page designer was created by an entry level
    >summer intern who never saw any reason for anyone to ever derive a custom
    >placeholder and accordingly they made sure that you couldn't.
    >

    Abstractly a nested master page can be considered as a custom
    ContentPlaceHolder. Depending upon your needs this might be the way to
    go.
    http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx
    If so you might want to reconsider the entry level summer intern
    comment.

    regards
    A.G.
    Registered User, Jun 24, 2009
    #6
  7. Allen Chen [MSFT]

    gerry Guest

    Sorry, but I am not seeing the relevance.
    While that may or may not be true abstractly, concretely it would be design
    & maintenance nightmare.

    Where one can simply drop multiple CustomContentPlaceHolders on a MasterPage
    ,
    a similar scheme using nested masterpaged would involve basing a MasterPage
    on a CustomMasterPage which is based on different CustomMasterPage2 which is
    based on another different CustomMasterPage3 etc.
    So instead of 1 CustomContentPlaceHolders you are suggesting multiple
    CustomMasterPages ? I don't even want to think about it.

    I stick by my intern comment - I see no valid reason to not be able to use a
    custom ContentPlaceHolder the same way we would use any other custom
    control.


    "Registered User" <> wrote in message
    news:...
    > On Wed, 24 Jun 2009 12:03:47 -0400, "gerry" <>
    > wrote:
    >
    >>Sounds like we are SOL on this one due to some 'by design' bug in the
    >>designer.
    >>My guess is that the master page designer was created by an entry level
    >>summer intern who never saw any reason for anyone to ever derive a custom
    >>placeholder and accordingly they made sure that you couldn't.
    >>

    > Abstractly a nested master page can be considered as a custom
    > ContentPlaceHolder. Depending upon your needs this might be the way to
    > go.
    > http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx
    > If so you might want to reconsider the entry level summer intern
    > comment.
    >
    > regards
    > A.G.
    gerry, Jun 25, 2009
    #7
  8. Allen Chen [MSFT]

    gerry Guest

    Sorry, but I am not seeing the relevance.
    While that may or may not be true abstractly, concretely it would be a
    design
    & maintenance nightmare.

    Where one can simply drop multiple CustomContentPlaceHolders on a MasterPage
    ,
    a similar scheme using nested masterpaged would involve basing a MasterPage
    on a CustomMasterPage which is based on different CustomMasterPage2 which is
    based on another different CustomMasterPage3 etc.
    So instead of 1 CustomContentPlaceHolders you are suggesting multiple
    CustomMasterPages ? I don't even want to think about it.

    I stick by my intern comment - I see no valid reason to not be able to use a
    custom ContentPlaceHolder the same way we would use any other custom
    control, say a custom Panel.
    Even if someone did come with a 'valid' reason it would in all likelihood
    still come down to trying to justify simply bad design.


    "Registered User" <> wrote in message
    news:...
    > On Wed, 24 Jun 2009 12:03:47 -0400, "gerry" <>
    > wrote:
    >
    >>Sounds like we are SOL on this one due to some 'by design' bug in the
    >>designer.
    >>My guess is that the master page designer was created by an entry level
    >>summer intern who never saw any reason for anyone to ever derive a custom
    >>placeholder and accordingly they made sure that you couldn't.
    >>

    > Abstractly a nested master page can be considered as a custom
    > ContentPlaceHolder. Depending upon your needs this might be the way to
    > go.
    > http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx
    > If so you might want to reconsider the entry level summer intern
    > comment.
    >
    > regards
    > A.G.
    gerry, Jun 25, 2009
    #8
  9. On Thu, 25 Jun 2009 13:12:37 -0400, "gerry" <>
    wrote:

    >Sorry, but I am not seeing the relevance.
    >While that may or may not be true abstractly, concretely it would be a
    >design
    >& maintenance nightmare.
    >
    >Where one can simply drop multiple CustomContentPlaceHolders on a MasterPage
    >,
    >a similar scheme using nested masterpaged would involve basing a MasterPage
    >on a CustomMasterPage which is based on different CustomMasterPage2 which is
    >based on another different CustomMasterPage3 etc.
    >So instead of 1 CustomContentPlaceHolders you are suggesting multiple
    >CustomMasterPages ? I don't even want to think about it.
    >

    Well I admit I'm unaware of your specific needs.

    >I stick by my intern comment - I see no valid reason to not be able to use a
    >custom ContentPlaceHolder the same way we would use any other custom
    >control, say a custom Panel.


    One reason might be the functionality of the types and their base
    classes (Control vs. WebControl) and the fact that ContentPlaceHolder
    implements the INamingContainer interface.
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.contentplaceholder.aspx
    "A ContentPlaceHolder control defines a relative region for content
    in a master page, and renders all text, markup, and server controls
    from a related Content control found in a content page."
    That doesn't describe any type derived from the WebControl class.

    And of course it doesn't explain the issues with deriving a type from
    the ContentPlaceHolder type.

    >Even if someone did come with a 'valid' reason it would in all likelihood
    >still come down to trying to justify simply bad design.
    >

    I can't call it a bad design without understanding the additional
    functionality the derived type will bring. Perhaps that functionality
    could be provided by using Extension methods eliminating the need to
    derive from the ContentPlaceHolder type.
    http://msdn.microsoft.com/en-us/library/bb383977.aspx

    If the intent is to add default content within the custom type
    consider the behavior of the base class.
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.contentplaceholder.aspx
    "You can specify default content placed within the ContentPlaceHolder
    control tags, but this content is replaced by any content in an
    associated content page."

    The intern comment denigrates the efforts of everyone involved in the
    design and production of the .NET framework.

    regards
    A.G.

    >
    >"Registered User" <> wrote in message
    >news:...
    >> On Wed, 24 Jun 2009 12:03:47 -0400, "gerry" <>
    >> wrote:
    >>
    >>>Sounds like we are SOL on this one due to some 'by design' bug in the
    >>>designer.
    >>>My guess is that the master page designer was created by an entry level
    >>>summer intern who never saw any reason for anyone to ever derive a custom
    >>>placeholder and accordingly they made sure that you couldn't.
    >>>

    >> Abstractly a nested master page can be considered as a custom
    >> ContentPlaceHolder. Depending upon your needs this might be the way to
    >> go.
    >> http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx
    >> If so you might want to reconsider the entry level summer intern
    >> comment.
    >>
    >> regards
    >> A.G.

    >
    >
    Registered User, Jun 25, 2009
    #9
  10. Allen Chen [MSFT]

    gerry Guest

    "Registered User" <> wrote in message
    news:...
    > On Thu, 25 Jun 2009 13:12:37 -0400, "gerry" <>
    > wrote:
    >
    >>Sorry, but I am not seeing the relevance.
    >>While that may or may not be true abstractly, concretely it would be a
    >>design
    >>& maintenance nightmare.
    >>
    >>Where one can simply drop multiple CustomContentPlaceHolders on a
    >>MasterPage
    >>,
    >>a similar scheme using nested masterpaged would involve basing a
    >>MasterPage
    >>on a CustomMasterPage which is based on different CustomMasterPage2 which
    >>is
    >>based on another different CustomMasterPage3 etc.
    >>So instead of 1 CustomContentPlaceHolders you are suggesting multiple
    >>CustomMasterPages ? I don't even want to think about it.
    >>

    > Well I admit I'm unaware of your specific needs.
    >
    >>I stick by my intern comment - I see no valid reason to not be able to use
    >>a
    >>custom ContentPlaceHolder the same way we would use any other custom
    >>control, say a custom Panel.

    >
    > One reason might be the functionality of the types and their base
    > classes (Control vs. WebControl)


    PlaceHolder & UpdatePanel are also Control based and custom versions work
    fine.

    > and the fact that ContentPlaceHolder
    > implements the INamingContainer interface.


    as do Panel , PlaceHolder , View , ListView , Repeater , UpdatePanel , ...
    custom versions each work fine

    > http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.contentplaceholder.aspx
    > "A ContentPlaceHolder control defines a relative region for content
    > in a master page, and renders all text, markup, and server controls
    > from a related Content control found in a content page."
    > That doesn't describe any type derived from the WebControl class.
    >
    > And of course it doesn't explain the issues with deriving a type from
    > the ContentPlaceHolder type.
    >
    >>Even if someone did come with a 'valid' reason it would in all likelihood
    >>still come down to trying to justify simply bad design.
    >>

    > I can't call it a bad design without understanding the additional
    > functionality the derived type will bring.


    ok - now you are espousing exactly the mind set that I expect is at the
    bottom of this issue, that being, that if you, the designer/developer, can't
    think of a reason why you would want to derive from a type then you make
    sure that nobody can else derive from that type even if they do have a
    perfectly good reason to.

    > Perhaps that functionality
    > could be provided by using Extension methods eliminating the need to
    > derive from the ContentPlaceHolder type.
    > http://msdn.microsoft.com/en-us/library/bb383977.aspx
    >
    > If the intent is to add default content within the custom type
    > consider the behavior of the base class.
    > http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.contentplaceholder.aspx
    > "You can specify default content placed within the ContentPlaceHolder
    > control tags, but this content is replaced by any content in an
    > associated content page."


    although it is irrelevant to the discussion of this undocumented 'feature'
    of the ContentPlaceHolder, in this particular case, the intent was to
    override the Render method to capture the rendered content, but I'm sure
    there are any number of valid reasons.

    >
    > The intern comment denigrates the efforts of everyone involved in the
    > design and production of the .NET framework.


    The comment wasn't directed at the designers/developers of the .NET
    framework, just the designer/developer of the web form designer , and if the
    shoe fits ...

    If the ContentPlaceHolder was intentionally meant to be unusable as a base
    class then it should have been sealed.
    It also worth noting that the custom ContentPlaceHolder control works just
    fine at runtime, this a 100% designer issue.


    >
    > regards
    > A.G.
    >
    >>
    >>"Registered User" <> wrote in message
    >>news:...
    >>> On Wed, 24 Jun 2009 12:03:47 -0400, "gerry" <>
    >>> wrote:
    >>>
    >>>>Sounds like we are SOL on this one due to some 'by design' bug in the
    >>>>designer.
    >>>>My guess is that the master page designer was created by an entry level
    >>>>summer intern who never saw any reason for anyone to ever derive a
    >>>>custom
    >>>>placeholder and accordingly they made sure that you couldn't.
    >>>>
    >>> Abstractly a nested master page can be considered as a custom
    >>> ContentPlaceHolder. Depending upon your needs this might be the way to
    >>> go.
    >>> http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx
    >>> If so you might want to reconsider the entry level summer intern
    >>> comment.
    >>>
    >>> regards
    >>> A.G.

    >>
    >>
    gerry, Jun 25, 2009
    #10
  11. On Thu, 25 Jun 2009 16:40:20 -0400, "gerry" <>
    wrote:
    >
    >"Registered User" <> wrote in message
    >news:...
    >> On Thu, 25 Jun 2009 13:12:37 -0400, "gerry" <>
    >> wrote:
    >>


    >
    >although it is irrelevant to the discussion of this undocumented 'feature'
    >of the ContentPlaceHolder, in this particular case, the intent was to
    >override the Render method to capture the rendered content, but I'm sure
    >there are any number of valid reasons.
    >

    Can the content actually be captured in the derived class' overridden
    Render method without infinite recursion?
    >>
    >> The intern comment denigrates the efforts of everyone involved in the
    >> design and production of the .NET framework.

    >
    >The comment wasn't directed at the designers/developers of the .NET
    >framework, just the designer/developer of the web form designer , and if the
    >shoe fits ...
    >

    There are many reviews between conceptualization and release. No one
    individual or small group is given free rein to do what they think is
    best with no oversight. There are constraints which are unknown to us
    and hopefully these constraints will be designed out of future
    versions of the tools. In the meantime you're painting with a broad
    brush.

    >If the ContentPlaceHolder was intentionally meant to be unusable as a base
    >class then it should have been sealed.
    >It also worth noting that the custom ContentPlaceHolder control works just
    >fine at runtime, this a 100% designer issue.
    >

    Yes there is a designer issue and it has been acknowledged. Knowing
    what you're trying to do makes the real question; is a derived
    ContentPlaceHolder necessary to capture the content? Add an
    OnPreRender event handler to a ContentPlaceHolder instance. Put the
    code below into the handler and make the appropriate change to
    control's ID.

    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    ContentPlaceHolder1.RenderControl(htw);
    string s = sb.ToString();

    The string s will contain the ContentPlaceHolder's content. If the
    content can be captured without using a derived class, does the valid
    reason to derive a class still exist? Explaining what the real task
    actually is can lead to simpler/unconsidered solutions. Hopefully this
    solution is suitable for your needs.

    regards
    A.G.
    Registered User, Jun 26, 2009
    #11
  12. Allen Chen [MSFT]

    gerry Guest

    "Registered User" <> wrote in message
    news:...
    > On Thu, 25 Jun 2009 16:40:20 -0400, "gerry" <>
    > wrote:
    >>
    >>"Registered User" <> wrote in message
    >>news:...
    >>> On Thu, 25 Jun 2009 13:12:37 -0400, "gerry" <>
    >>> wrote:
    >>>

    >
    >>
    >>although it is irrelevant to the discussion of this undocumented 'feature'
    >>of the ContentPlaceHolder, in this particular case, the intent was to
    >>override the Render method to capture the rendered content, but I'm sure
    >>there are any number of valid reasons.
    >>

    > Can the content actually be captured in the derived class' overridden
    > Render method without infinite recursion?


    why not - where do you see recursion in this ?

    protected override void Render(HtmlTextWriter writer)
    {
    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    base .Render(htw);

    string content= sb.ToString();

    writer.write(content);

    // ... do whatever else with content
    }

    >>>
    >>> The intern comment denigrates the efforts of everyone involved in the
    >>> design and production of the .NET framework.

    >>
    >>The comment wasn't directed at the designers/developers of the .NET
    >>framework, just the designer/developer of the web form designer , and if
    >>the
    >>shoe fits ...
    >>

    > There are many reviews between conceptualization and release. No one
    > individual or small group is given free rein to do what they think is
    > best with no oversight. There are constraints which are unknown to us
    > and hopefully these constraints will be designed out of future
    > versions of the tools. In the meantime you're painting with a broad
    > brush.


    Some things slip through, especially when noone has thought to test for
    them.
    But more to the point, poor ( short-sighted ) design - case in point , the
    framework classes that started out as either internal or sealed or both in
    earlier releases that were eventually made public and/or unsealed because
    there actually were valid reasons for it.

    >
    >>If the ContentPlaceHolder was intentionally meant to be unusable as a base
    >>class then it should have been sealed.
    >>It also worth noting that the custom ContentPlaceHolder control works just
    >>fine at runtime, this a 100% designer issue.
    >>

    > Yes there is a designer issue and it has been acknowledged. Knowing
    > what you're trying to do makes the real question; is a derived
    > ContentPlaceHolder necessary to capture the content? Add an
    > OnPreRender event handler to a ContentPlaceHolder instance. Put the
    > code below into the handler and make the appropriate change to
    > control's ID.
    >
    > StringBuilder sb = new StringBuilder();
    > StringWriter sw = new StringWriter(sb);
    > HtmlTextWriter htw = new HtmlTextWriter(sw);
    > ContentPlaceHolder1.RenderControl(htw);
    > string s = sb.ToString();
    >


    calling render before PreRender has completed or PreRenderComplete has
    executed and knowing that PreRender will be called again in the proper
    request event sequence sounds pretty hoky.
    did you even try this ?
    I did - any server controls contained in the ContentPlaceHolder will barf
    with a "must be placed inside a form tag with runat=server. " error - not
    surprising.
    My guess is that any databound controls would also have problems with being
    rendered twice - that is if they could get past issue just stated.

    > The string s will contain the ContentPlaceHolder's content.


    No it won't.

    > If the content can be captured without using a derived class, does the
    > valid
    > reason to derive a class still exist?


    Who knows, I don't pretend to know every possible reason for deriving such a
    custom control.

    > Explaining what the real task actually is can lead to simpler/unconsidered
    > solutions.
    > Hopefully this solution is suitable for your needs.


    Nope

    >
    > regards
    > A.G.
    gerry, Jun 26, 2009
    #12
  13. On Fri, 26 Jun 2009 10:40:32 -0400, "gerry" <>
    wrote:

    >
    >"Registered User" <> wrote in message
    >news:...
    >> On Thu, 25 Jun 2009 16:40:20 -0400, "gerry" <>
    >> wrote:
    >>>
    >>>"Registered User" <> wrote in message
    >>>news:...
    >>>> On Thu, 25 Jun 2009 13:12:37 -0400, "gerry" <>
    >>>> wrote:
    >>>>

    >>
    >>>
    >>>although it is irrelevant to the discussion of this undocumented 'feature'
    >>>of the ContentPlaceHolder, in this particular case, the intent was to
    >>>override the Render method to capture the rendered content, but I'm sure
    >>>there are any number of valid reasons.
    >>>

    >> Can the content actually be captured in the derived class' overridden
    >> Render method without infinite recursion?

    >
    >why not - where do you see recursion in this ?
    >
    > protected override void Render(HtmlTextWriter writer)
    > {
    > StringBuilder sb = new StringBuilder();
    > StringWriter sw = new StringWriter(sb);
    > HtmlTextWriter htw = new HtmlTextWriter(sw);
    > base .Render(htw);
    >
    > string content= sb.ToString();
    >
    > writer.write(content);
    >
    > // ... do whatever else with content
    > }
    >

    I was asking a question not saying there would be recursion.

    >>>>
    >>>> The intern comment denigrates the efforts of everyone involved in the
    >>>> design and production of the .NET framework.
    >>>
    >>>The comment wasn't directed at the designers/developers of the .NET
    >>>framework, just the designer/developer of the web form designer , and if
    >>>the
    >>>shoe fits ...
    >>>

    >> There are many reviews between conceptualization and release. No one
    >> individual or small group is given free rein to do what they think is
    >> best with no oversight. There are constraints which are unknown to us
    >> and hopefully these constraints will be designed out of future
    >> versions of the tools. In the meantime you're painting with a broad
    >> brush.

    >
    >Some things slip through, especially when noone has thought to test for
    >them.
    >But more to the point, poor ( short-sighted ) design - case in point , the
    >framework classes that started out as either internal or sealed or both in
    >earlier releases that were eventually made public and/or unsealed because
    >there actually were valid reasons for it.
    >
    >>
    >>>If the ContentPlaceHolder was intentionally meant to be unusable as a base
    >>>class then it should have been sealed.
    >>>It also worth noting that the custom ContentPlaceHolder control works just
    >>>fine at runtime, this a 100% designer issue.
    >>>

    >> Yes there is a designer issue and it has been acknowledged. Knowing
    >> what you're trying to do makes the real question; is a derived
    >> ContentPlaceHolder necessary to capture the content? Add an
    >> OnPreRender event handler to a ContentPlaceHolder instance. Put the
    >> code below into the handler and make the appropriate change to
    >> control's ID.
    >>
    >> StringBuilder sb = new StringBuilder();
    >> StringWriter sw = new StringWriter(sb);
    >> HtmlTextWriter htw = new HtmlTextWriter(sw);
    >> ContentPlaceHolder1.RenderControl(htw);
    >> string s = sb.ToString();
    >>

    >
    >calling render before PreRender has completed or PreRenderComplete has
    >executed and knowing that PreRender will be called again in the proper
    >request event sequence sounds pretty hoky.
    >did you even try this ?

    Yes and the OnPreRender event is only fired once.

    >I did - any server controls contained in the ContentPlaceHolder will barf
    >with a "must be placed inside a form tag with runat=server. " error - not
    >surprising.

    I did not experience any problems with this using VS2008.

    >My guess is that any databound controls would also have problems with being
    >rendered twice - that is if they could get past issue just stated.
    >

    I did not try databound controls so I won't make any guesses about
    rendering the same databound control twice, each time to a different
    stream. What impact to the databinding is expected when a control is
    rendered twice to different streams?

    Admittedly the OnPreRender event may not be the most suitable
    location. The same code could be placed in the master page's Page_Load
    method. In the example shown at the link below the databound control
    gets rendered twice with no issues.
    http://www.4guysfromrolla.com/articles/091102-1.aspx


    >> The string s will contain the ContentPlaceHolder's content.

    >
    >No it won't.
    >

    I did try it using server controls and the string was as expected with
    no errors.

    >> If the content can be captured without using a derived class, does the
    >> valid
    >> reason to derive a class still exist?

    >
    >Who knows, I don't pretend to know every possible reason for deriving such a
    >custom control.
    >

    Re-read the the sentence again and note the explicit reason of
    capturing content.

    >> Explaining what the real task actually is can lead to simpler/unconsidered
    >> solutions.


    >> Hopefully this solution is suitable for your needs.

    >
    >Nope
    >

    I've tried and apparently failed to explain that a custom
    ContentPlaceHolder is not required to accomplish the task. If you feel
    it is necessary to use a ContentPlaceHolder-derived type to capture
    the content then do it and deal with the designer issue. If the
    designer issue shows itself to be an obstacle, you may want to
    reconsider possible alternatives.

    regards
    A.G.

    >>
    >> regards
    >> A.G.

    >
    Registered User, Jun 26, 2009
    #13
  14. On Fri, 26 Jun 2009 16:41:34 -0400, "gerry" <>
    wrote:

    >attached is a simple project with a master page containing a single
    >ContentPlaceHolder
    >and a ContentPage that places a single textbox in the ContentPlaceHolder
    >
    >trying to capture the generated ContentPlaceHolder content in the
    >ContentPlaceHolder1_PreRender , Page_Load or Page_PreRenderComplete
    >all generate the same "must be placed inside a form tag with runat=server. "
    >error.
    >
    >I must be doing something wrong if you can do this without any errors - any
    >idea what ?
    >

    You used the wrong server control. No, seriously I used a label in my
    quickie test.
    -snip -
    >>>

    >> I was asking a question not saying there would be recursion.

    >
    >And I was asking in case you see something that I don't.
    >

    -snip -
    >> Yes and the OnPreRender event is only fired once.

    >
    >Typo there - should have been Render will be called again.

    No problem with it being a typo. These things happen.
    >
    >>

    - snip -
    >> http://www.4guysfromrolla.com/articles/091102-1.aspx

    >
    >and that article also links to a second article because it only works with
    >pre 2.0 versions of the framework.
    >the method generates errors in 2.0+ - he did run into a different error so
    >there are obviously multiple problems with this solution
    >calling the Render method at any time before the Page_PreRenderComplete has
    >fired could generate invalid results due to code in the contained controls
    >PreRender that will not have had a chance to fire.
    >

    I scanned the article quickly as I've got my own managers trying to
    boil the ocean.
    - snip -
    >>
    >>>> Hopefully this solution is suitable for your needs.
    >>>
    >>>Nope
    >>>

    And now I see why it's not suitable and understand your frustration
    with a derived ContentPlaceHolder type's behavior.

    >> I've tried and apparently failed to explain that a custom
    >> ContentPlaceHolder is not required to accomplish the task. If you feel
    >> it is necessary to use a ContentPlaceHolder-derived type to capture
    >> the content then do it and deal with the designer issue. If the
    >> designer issue shows itself to be an obstacle, you may want to
    >> reconsider possible alternatives.

    >

    I should have written "may not be required".

    >We are pretty much giving up on this for now.
    >

    I try to avoid asking the 'why' question because too often the
    question is taken as a personal affront. The question isn't really
    about an 'requirement' being good or bad as much as 'is it really a
    necessary requirement?' That question would be in my mind even if a
    derived ContentPlaceHolder worked as it should in the designer.

    Sometimes not doing something can be a viable alternative. This might
    be suitable for you situation or maybe nested master pages. Another
    option might be to put each ContentPlaceHolder inside of a div,
    capture the entire page's content, and then parse the content for the
    divs using a DOM. I'm not saying this would work but you might want to
    try it and see depending upon the status of the requirement.

    I appreciate the time you've taken to explain the issues you've run up
    against. Hopefully that time is billable ;)

    regards
    A.G.
    Registered User, Jun 27, 2009
    #14
  15. Allen Chen [MSFT]

    gerry Guest

    "Registered User" <> wrote in message
    news:p...
    > On Fri, 26 Jun 2009 16:41:34 -0400, "gerry" <>
    > wrote:
    >

    ....

    >
    >>We are pretty much giving up on this for now.
    >>

    > I try to avoid asking the 'why' question because too often the
    > question is taken as a personal affront. The question isn't really
    > about an 'requirement' being good or bad as much as 'is it really a
    > necessary requirement?' That question would be in my mind even if a
    > derived ContentPlaceHolder worked as it should in the designer.
    >
    > Sometimes not doing something can be a viable alternative. This might
    > be suitable for you situation or maybe nested master pages. Another
    > option might be to put each ContentPlaceHolder inside of a div,


    Actually we did get this to work by wrapping the ContentPlaceHolder in the
    master page within a custom Panel. It requires an additional bit of markup
    per placeholder but it lets us encapsulate the required functionality within
    one control and it works.

    > capture the entire page's content, and then parse the content for the
    > divs using a DOM. I'm not saying this would work but you might want to
    > try it and see depending upon the status of the requirement.
    >
    > I appreciate the time you've taken to explain the issues you've run up
    > against. Hopefully that time is billable ;)
    >
    > regards
    > A.G.
    >
    >
    gerry, Jun 27, 2009
    #15
    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. Billy Cormic

    master pages contentplaceholder

    Billy Cormic, Aug 31, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    562
    Billy Cormic
    Sep 1, 2004
  2. Sebastian Meier
    Replies:
    0
    Views:
    399
    Sebastian Meier
    Apr 23, 2005
  3. Beatniks
    Replies:
    0
    Views:
    473
    Beatniks
    Dec 23, 2005
  4. Greg
    Replies:
    4
    Views:
    14,869
    dassyms
    Apr 17, 2006
  5. Greg
    Replies:
    1
    Views:
    193
    Ward Bekker
    Mar 23, 2006
Loading...

Share This Page