Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Web Custom Control - Design Time Support ? ? ?

Reply
Thread Tools

Web Custom Control - Design Time Support ? ? ?

 
 
MLibby
Guest
Posts: n/a
 
      09-03-2004
How do I implement design time support for a web custom control? For some
reason the control can't seem to find System.Web.UI.Design and I get the
following compiler error:

C:\Documents and Settings\MLibby\My Documents\Visual Studio
Projects\CustomControlEnum\CustCtrlDesigner\CustCt rl.cs(3): The type or
namespace name 'Design' does not exist in the class or namespace
'System.Web.UI' (are you missing an assembly reference?)

Here's my code.

using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace CustCtrlDesigner
{
/// <summary>
/// Summary description for CustCtrl.
/// </summary>

[DesignerAttribute(typeof(CustCtrlDesigner), typeof(IDesigner))]
public class CustCtrl : System.Web.UI.WebControls.WebControl
{
protected override void Render(HtmlTextWriter output)
{
output.Write("<center><font size='30'>");
output.Write( "Rendered!");
output.Write("</font></center>");
}
}

public class CustCtrlDesigner : System.Web.UI.Design.ControlDesigner
{
public override string GetDesignTimeHtml()
{
string html = base.GetDesignTimeHtml();

output.Write("<center><font size='30'>");
output.Write( "Designer!");
output.Write("</font></center>");
}
}
}

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      09-04-2004
Hi Mlibby,

As for the compile error you mentioned, I think the problem is likely
caused by the required assemblies not
be referenced in your project. Just add the "using ..." statement is not
enought. We should also reference the
the required assemblies via the "Add Reference" function in the VS.NET IDE,
and we need to add the following assemblies:

System.Design.dll

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


 
Reply With Quote
 
 
 
 
MLibby
Guest
Posts: n/a
 
      09-04-2004
Thank you Steven, that fixed it.

New question, how do I keep the Render method from outputing during design
mode? Currently both the rendered text and GetDesignTimeHtml text are
showing up in design mode.

Mike
 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      09-04-2004
Hi Mike,

I think the problem that the design-time output both the desiger's and the
control's render content is caused by the "base.GetDesignTimeHtml()" you
called. This will return the html using the Control's Render method.

So if you want to use the Designer's output, please comment the

string html = base.GetDesignTimeHtml();

Just use your override code. thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


 
Reply With Quote
 
MLibby
Guest
Posts: n/a
 
      09-04-2004
That worked! Thank you Steven.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Control - Design Time Support =?Utf-8?B?U2ltb24=?= ASP .Net 0 01-24-2007 09:51 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net Web Controls 0 06-01-2005 02:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net Building Controls 1 07-02-2003 08:05 AM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments