Clever ways to work around the fact that control breaks VS.NET design view? (replacing a literal?)

Discussion in 'ASP .Net' started by Ken Fine, Aug 26, 2007.

  1. Ken Fine

    Ken Fine Guest

    I'm using ASP.NET and VS.NET 2008 beta. (This is not specifically a VS.NET
    beta question -- it IS an ASP.NET Q -- so please keep reading.)

    Scott M. made a very nice control to dynamically generate rounded corners:
    http://datawebcontrols.com/demos/RoundedCorners.aspx

    This control functions with the design view in VS.NET 2005 but appears to
    break in the design view in VS.NET 2008. Explanation: Scott's control can
    "wrap" other content, and in VS.NET the content inside the rounded corner
    control is hidden. Nontheless, the control works fine when rendered.

    I am wondering what clever ways I might be able to use to retain my design
    view in VS.NET 2008 while still calling Scott's code at runtime. I am sure
    there is a way. I list some options shortly.

    In ASPX it is called like this:

    <cc1:RoundedCorners ID="Roundedcorners3" ShowTitle="False" Title="Test"
    runat="server BackColor="#FFFFFF" BorderColor="Gold" BorderStyle="Solid"
    BorderWidth="3px"
    Font-Names="Verdana"
    ImageDirectory="~/RoundedCornersTester/Images/" Font-Size="11px"
    Width="100%" Padding="2px"
    HorizontalAlign="Right" TitleStyle-BackColor="#C0C0FF"
    CornerHeight="15px"
    BackgroundBackColor="#3A265A" align="Right" >

    [ whatever content you want inside the rounded corner control goes here ]

    </cc1:RoundedCorners>

    So I am familiar with the notion of dynamically calling controls from
    codebehind, but I don't think that works here since you are "wrapping" other
    controls and content.

    Some options I see include:
    1) Somehow specifying comment characters in the declarative ASPX, and
    programmatically removing those comment characters at runtime. Right now I'm
    manually inserting comment characters in the markup and removing them by
    hand when I deploy.

    2) Somehow injecting the entire block of declarative ASPX programmatically
    at runtime, but prior to the time the aspx markup is parsed and rendered. I
    don't even know if this is possible: I'm interested if it is. We would need
    to programmatically inject the opening tag and the closing tag. Based on
    other examples I've read involving a mysterious something called a
    "literal", I think this may be possible.

    3) Something else cleaner that I'm not quite fathoming.

    Any help out there in net land?

    Thank you,
    -KF
    Ken Fine, Aug 26, 2007
    #1
    1. Advertising

  2. Hi Ken,

    I've downloaded the control as you mentioned and loaded into VS2008 Beta 2.
    I can see the control was origionally written for VS2003, therefore it's
    using some obsolete class such as the custom control designer.

    Actually if remove the custom control designer and replace it with the
    suggested ContainerControlDesigner:

    [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    Designer(typeof(ContainerControlDesigner))]
    public class RoundedCorners : System.Web.UI.WebControls.WebControl



    It should work correctly in design time.


    Hope this helps.



    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Aug 27, 2007
    #2
    1. Advertising

  3. "Ken Fine" <> wrote in message
    news:...

    > Scott M. made a very nice control to dynamically generate rounded corners:
    > http://datawebcontrols.com/demos/RoundedCorners.aspx


    I made the most recent changes to this control, specifically updates for
    ASP.NET 2 and XHTML-compliance...

    I must admit I've not tried it in Orcas yet. However, the download from the
    4GuysFromRolla site
    (http://aspnet.4guysfromrolla.com/code/RoundedCorners.zip) includes the full
    source code for the control, so feel free to experiment with it...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 27, 2007
    #3
  4. Ken Fine

    Ken Fine Guest

    Hi Walter,

    Thank you very much for the investigation: it's above and beyond the call.
    Can you tell me how you "remove the custom control designer and replace it
    with the suggested ContainerControlDesigner"? Where in code (or in the tool)
    do you make that change?

    Thanks again,
    -KF


    ""Walter Wang [MSFT]"" <> wrote in message
    news:...
    > Hi Ken,
    >
    > I've downloaded the control as you mentioned and loaded into VS2008 Beta
    > 2.
    > I can see the control was origionally written for VS2003, therefore it's
    > using some obsolete class such as the custom control designer.
    >
    > Actually if remove the custom control designer and replace it with the
    > suggested ContainerControlDesigner:
    >
    > [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    > ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    > Designer(typeof(ContainerControlDesigner))]
    > public class RoundedCorners : System.Web.UI.WebControls.WebControl
    >
    >
    >
    > It should work correctly in design time.
    >
    >
    > Hope this helps.
    >
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    Ken Fine, Aug 27, 2007
    #4
  5. Ken Fine

    Ken Fine Guest

    The control is very good and very useful. Nice work on it, Mark!

    -KF

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Ken Fine" <> wrote in message
    > news:...
    >
    >> Scott M. made a very nice control to dynamically generate rounded
    >> corners: http://datawebcontrols.com/demos/RoundedCorners.aspx

    >
    > I made the most recent changes to this control, specifically updates for
    > ASP.NET 2 and XHTML-compliance...
    >
    > I must admit I've not tried it in Orcas yet. However, the download from
    > the 4GuysFromRolla site
    > (http://aspnet.4guysfromrolla.com/code/RoundedCorners.zip) includes the
    > full source code for the control, so feel free to experiment with it...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Ken Fine, Aug 27, 2007
    #5
  6. Hi Ken,

    If you open the file RoundedCornersDesign.cs in VS2005 or 2008, the IDE
    should notify you that the ReadWriteControlDesigner is now obsolete and you
    should use ContainerControlDesigner instead.

    Now, open the file RoundedCorners.cs, change:

    [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    Designer(typeof(PrettyUI.Design.RoundedCornersDesign))]
    public class RoundedCorners : System.Web.UI.WebControls.WebControl
    {

    into:


    [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    Designer(typeof(System.Web.UI.Design.ContainerControlDesigner))]
    public class RoundedCorners : System.Web.UI.WebControls.WebControl
    {


    You should see it works in VS2008. Let me know if you still have trouble to
    make it work.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Aug 28, 2007
    #6
  7. Ken Fine

    Ken Fine Guest

    Thanks again Walter. As always you are extremely helpful.

    Best,
    -KF


    ""Walter Wang [MSFT]"" <> wrote in message
    news:...
    > Hi Ken,
    >
    > If you open the file RoundedCornersDesign.cs in VS2005 or 2008, the IDE
    > should notify you that the ReadWriteControlDesigner is now obsolete and
    > you
    > should use ContainerControlDesigner instead.
    >
    > Now, open the file RoundedCorners.cs, change:
    >
    > [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    > ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    > Designer(typeof(PrettyUI.Design.RoundedCornersDesign))]
    > public class RoundedCorners : System.Web.UI.WebControls.WebControl
    > {
    >
    > into:
    >
    >
    > [DefaultProperty("Text"), PersistChildren(true), ParseChildren(false),
    > ToolboxData("<{0}:RoundedCorners runat=server></{0}:RoundedCorners>"),
    > Designer(typeof(System.Web.UI.Design.ContainerControlDesigner))]
    > public class RoundedCorners : System.Web.UI.WebControls.WebControl
    > {
    >
    >
    > You should see it works in VS2008. Let me know if you still have trouble
    > to
    > make it work.
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    Ken Fine, Aug 29, 2007
    #7
  8. Ken Fine

    Ken Fine Guest

    Thanks and Instructions Re: Clever ways to work around the fact that control breaks VS.NET design view? (replacing a literal?)

    Thanks. This works great now (albeit with a small bit of display funkiness
    that is doubtless VS.NET 2008's issue.)

    For any other newbs trying to get this going, here's whatcha gotta do:
    a) add a project to your solution for a "Server Control"
    b) Right-click on "References" and be sure to add "System.Design" to the
    reference list
    c) Sub in Walter's code
    d) You must allow unsafe code in compilation. Right click on the project you
    made for the server control, go to "build", and choose the "unsafe code"
    option
    e) I compiled for .NET 3.5 and all seems well.

    Appreciate the help.

    -KF
    "Ken Fine" <> wrote in message
    news:...
    > I'm using ASP.NET and VS.NET 2008 beta. (This is not specifically a VS.NET
    > beta question -- it IS an ASP.NET Q -- so please keep reading.)
    >
    > Scott M. made a very nice control to dynamically generate rounded corners:
    > http://datawebcontrols.com/demos/RoundedCorners.aspx
    >
    > This control functions with the design view in VS.NET 2005 but appears to
    > break in the design view in VS.NET 2008. Explanation: Scott's control can
    > "wrap" other content, and in VS.NET the content inside the rounded corner
    > control is hidden. Nontheless, the control works fine when rendered.
    >
    > I am wondering what clever ways I might be able to use to retain my design
    > view in VS.NET 2008 while still calling Scott's code at runtime. I am sure
    > there is a way. I list some options shortly.
    >
    > In ASPX it is called like this:
    >
    > <cc1:RoundedCorners ID="Roundedcorners3" ShowTitle="False" Title="Test"
    > runat="server BackColor="#FFFFFF" BorderColor="Gold" BorderStyle="Solid"
    > BorderWidth="3px"
    > Font-Names="Verdana"
    > ImageDirectory="~/RoundedCornersTester/Images/" Font-Size="11px"
    > Width="100%" Padding="2px"
    > HorizontalAlign="Right" TitleStyle-BackColor="#C0C0FF"
    > CornerHeight="15px"
    > BackgroundBackColor="#3A265A" align="Right" >
    >
    > [ whatever content you want inside the rounded corner control goes here ]
    >
    > </cc1:RoundedCorners>
    >
    > So I am familiar with the notion of dynamically calling controls from
    > codebehind, but I don't think that works here since you are "wrapping"
    > other controls and content.
    >
    > Some options I see include:
    > 1) Somehow specifying comment characters in the declarative ASPX, and
    > programmatically removing those comment characters at runtime. Right now
    > I'm manually inserting comment characters in the markup and removing them
    > by hand when I deploy.
    >
    > 2) Somehow injecting the entire block of declarative ASPX programmatically
    > at runtime, but prior to the time the aspx markup is parsed and rendered.
    > I don't even know if this is possible: I'm interested if it is. We would
    > need to programmatically inject the opening tag and the closing tag. Based
    > on other examples I've read involving a mysterious something called a
    > "literal", I think this may be possible.
    >
    > 3) Something else cleaner that I'm not quite fathoming.
    >
    > Any help out there in net land?
    >
    > Thank you,
    > -KF
    >
    Ken Fine, Aug 29, 2007
    #8
  9. Hi Ken,

    I'm glad that helped.

    By the way, have you changed your nospam posting alias recently? Could you
    please tell me your previous posting alias? Thanks.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Aug 29, 2007
    #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. Ed West
    Replies:
    1
    Views:
    1,590
  2. Aahz
    Replies:
    2
    Views:
    1,376
    Eliyahu Goldin
    Aug 1, 2005
  3. Martin Manns

    Long integers and ways around xrange

    Martin Manns, Jan 16, 2010, in forum: Python
    Replies:
    2
    Views:
    683
    Martin Manns
    Jan 16, 2010
  4. Parthiv Joshi
    Replies:
    1
    Views:
    644
    Samuel L Matzen
    Jul 6, 2004
  5. Ilias Lazaridis
    Replies:
    4
    Views:
    466
    Ilias Lazaridis
    Jun 21, 2011
Loading...

Share This Page