Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ken Fine - 26 Aug 2007 17:03 GMT
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
Walter Wang [MSFT] - 27 Aug 2007 11:40 GMT
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 (wawang@online.microsoft.com, 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 - 27 Aug 2007 16:42 GMT
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

> Hi Ken,
>
[quoted text clipped - 26 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 28 Aug 2007 06:20 GMT
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 (wawang@online.microsoft.com, 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 - 29 Aug 2007 05:19 GMT
Thanks again Walter. As always you are extremely helpful.

Best,
-KF

> Hi Ken,
>
[quoted text clipped - 34 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 29 Aug 2007 08:41 GMT
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 (wawang@online.microsoft.com, 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.
Mark Rae [MVP] - 27 Aug 2007 11:53 GMT
> 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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Ken Fine - 27 Aug 2007 16:43 GMT
The control is very good and very useful. Nice work on it, Mark!

-KF

>> Scott M. made a very nice control to dynamically generate rounded
>> corners: http://datawebcontrols.com/demos/RoundedCorners.aspx
[quoted text clipped - 6 lines]
> (http://aspnet.4guysfromrolla.com/code/RoundedCorners.zip) includes the
> full source code for the control, so feel free to experiment with it...
Ken Fine - 29 Aug 2007 06:01 GMT
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
> 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.)
[quoted text clipped - 50 lines]
> Thank you,
> -KF

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.