HighTechTalks DotNet Forums  

Web Custom Control - Design Time Support ? ? ?

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Web Custom Control - Design Time Support ? ? ? in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
MLibby
 
Posts: n/a

Default Web Custom Control - Design Time Support ? ? ? - 09-03-2004 , 05:19 PM






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
  #2  
Old   
AT
 
Posts: n/a

Default RE: Web Custom Control - Design Time Support ? ? ? - 09-03-2004 , 09:30 PM






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
  #3  
Old   
MLibby
 
Posts: n/a

Default RE: Web Custom Control - Design Time Support ? ? ? - 09-03-2004 , 09:45 PM



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
  #4  
Old   
AT
 
Posts: n/a

Default RE: Web Custom Control - Design Time Support ? ? ? - 09-04-2004 , 01:14 AM



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
  #5  
Old   
MLibby
 
Posts: n/a

Default RE: Web Custom Control - Design Time Support ? ? ? - 09-04-2004 , 08:57 AM



That worked! Thank you Steven.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.