C
Carole MacDonald
I'm trying to do the following:
public class MyControlDesigner : System.Web.UI.Design.ControlDesigner
{
private string m_html = "";
public string Html
{
get { return m_html; }
set { m_html = value; }
}
public override string GetDesignTimeHtml()
{
return m_html;
}
}
[DesignerAttribute(typeof(MyControlDesigner), typeof(IDesigner))]
public class MyControl : System.Web.UI.WebControls.WebControl
{
override void OnInit(EventArgs e)
{
System.ComponentModel.AttributeCollection attributes =
TypeDescriptor.GetAttributes(this);
DesignerAttribute myAttribute =
(DesignerAttribute)attributes[typeof(DesignerAttribute)];
// somehow set the Html property of the designer to a string
}
}
Where I'm stuck is getting an object reference to MyControlDesigner.
Is this possible? The reason I'm trying to do this is I have a bunch
of custom web controls where I want the GetDesignTimeHtml() to return
a simple string that will be different for each control. I'd rather
not create a different control designer for each one since they'd
basically be identical except for the returned string. My first
thought was to derive from DesignerAttribute so I could pass in
another argument with the html string, but that is a sealed class. So
then I tried to access the ControlDesigner to set the string
dynamically. Is this possible?
Thanks,
Carole
public class MyControlDesigner : System.Web.UI.Design.ControlDesigner
{
private string m_html = "";
public string Html
{
get { return m_html; }
set { m_html = value; }
}
public override string GetDesignTimeHtml()
{
return m_html;
}
}
[DesignerAttribute(typeof(MyControlDesigner), typeof(IDesigner))]
public class MyControl : System.Web.UI.WebControls.WebControl
{
override void OnInit(EventArgs e)
{
System.ComponentModel.AttributeCollection attributes =
TypeDescriptor.GetAttributes(this);
DesignerAttribute myAttribute =
(DesignerAttribute)attributes[typeof(DesignerAttribute)];
// somehow set the Html property of the designer to a string
}
}
Where I'm stuck is getting an object reference to MyControlDesigner.
Is this possible? The reason I'm trying to do this is I have a bunch
of custom web controls where I want the GetDesignTimeHtml() to return
a simple string that will be different for each control. I'd rather
not create a different control designer for each one since they'd
basically be identical except for the returned string. My first
thought was to derive from DesignerAttribute so I could pass in
another argument with the html string, but that is a sealed class. So
then I tried to access the ControlDesigner to set the string
dynamically. Is this possible?
Thanks,
Carole