Help With Designer for a Control

P

paul reed

Hi,

I have a control that I have built. After Jeffrey on this newsgroup educated
me about the event lifecycle of CreateChildControls...all is working as
planned.

Now I want to make the control more appealing when it is initially dragged
from the Toolbar and dropped onto the ASPX page (it is a tree view control
wrapped inside of a custom control).. Right now, after dropping the control
onto the design surface, it is a very small control that is almost not
ledgible. So, I know to make the widget look larger on the surface of the
page, lets say a rectangle 300px high and 250px wide, I need to provide a
designer for the control. I would also like to provide a very opaque border
around it so there is a visual reference to the size (much like what happens
when you drop a panel control onto a page). I would also like for there to
be some wording inside of the control just so they know what it is (i.e.,
ProjectX TreeView Control).

I built the designer but wasn't sure where to do this at. I tried
overloading the 'initalize' method and assigning these values but that
didn't do anything.

Exactly where should I be doing this in the designer? There are some samples
out there but they are not very descriptive.

Regards,

Paul
 
J

Jeffrey Tan[MSFT]

Hi Paul,

Thank you for posting in the community!

I will continue assist you on your further issue :)

Based on my understanding, you want to customize your web control's
designtime interface.

=================================================
Actually, VS.net provides a rich feature support for design-time behavior
of Web server control.
You can create a customized control designer for your control.(Inherit
System.Web.UI.Design.ControlDesigner class)

In the design time, VS.net will invoke ControlDesigner.GetDesignTimeHtml
method to return the design-time html view for your control. So you should
override this method and provide your own html view.

For your reqirement, I think you may use a <div> html tag, make it border
width and inner html. Like this:

public class mycontroldesigner: System.Web.UI.Design.ControlDesigner
{
public override string GetDesignTimeHtml()
{
StringBuilder sb=new StringBuilder();
sb.Append("<div style=\" BORDER-RIGHT:1px solid; BORDER-TOP: 1px solid;
BORDER-LEFT:1px solid; BORDER-BOTTOM: 1px solid;WIDTH: 250px; HEIGHT:
300px\">ProjectX TreeView Control</div>");
return sb.ToString();
}
}

Use it on your web control like this:

[Designer(typeof(mycontroldesigner),
typeof(System.ComponentModel.Design.IDesigner))]
public class yourwebcontrol
{
\\\\\\\
}

In the GetDesignTimeHtml method, I returns a <div> tag, whose 4 borders all
set to 1px solid. Then I set the Width and Height to your wanted value.

Actually, System.Web.UI.Design.ControlDesigner gives you more design-time
control over web control, please refer to the article below for more
information:
http://www.wdvl.com/Authoring/ASP/NET_Nutshell/asp_net3_2.html

=================================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
P

Paul Reed

Jeffrey,

Thanks again (a 3rd time!). Your assistance with my designer worked out
just fine. Now I am having a problem with my control not resizing for
some reason. However, I have place that issue in a different post.

Thanks again Jeffrey. I just received a request to answer a survey on
the support I have received recently and I gave you high marks!!!

Paul Reed
www.jacksonreed.com
 
J

Jeffrey Tan[MSFT]

Hi Paul,

Thanks very much for your feedback.

For your further issue, I will follow up you in that post.

Also, thanks very much for giving high marks for my support survey! I will
hold on my work. :)

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
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


Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top