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


K

Ken Fine

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
 
Ad

Advertisements

W

Walter Wang [MSFT]

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 ([email protected], 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.
 
M

Mark Rae [MVP]

K

Ken Fine

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
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 
Ad

Advertisements

K

Ken Fine

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 said:
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
 
Ad

Advertisements

W

Walter Wang [MSFT]

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 ([email protected], 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.
 

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

Similar Threads


Top