A
awburns
I have a custom server control I've written, which I've subclassed
from the System.Web.UI.Control class.
When I drag it from the toolbar to the page, the following text is put
into the aspx source:
<cc1:MyControl ID="MyControl1" runat="server">
</cc1:MyControl>
What I'd really like is to include some default attributes and values
in the default tag. I tried changing the ToolboxData attribute, which
is currently:
[ToolboxData("<{0}:MyControl runat=server></{0}:MyControl>")]
to
[ToolboxData("<{0}:MyControl runat=server SomeProp='SomeValue'></
{0}:MyControl>")]
But all that happened then is that the text in the aspx source was
created without an ID attribute.
I've tried setting the DefaultValue attribute of 'SomeProp', and even
changing it so it always returns a value:
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("DefaultPropValue")]
[Localizable(true)]
public string SomeProp
{
get
{
String s = (String)ViewState["SomeProp"];
return ((s == null) ? "DefaultPropValue" : s);
}
set
{
ViewState["SomeProp"] = value;
}
}
Despite this, the aspx tags are still created without extra
attributes.
Clearly this is possible, and I'm doing something wrong, but I'm
damned if I can figure out what...
Thanks in advance,
Andy
from the System.Web.UI.Control class.
When I drag it from the toolbar to the page, the following text is put
into the aspx source:
<cc1:MyControl ID="MyControl1" runat="server">
</cc1:MyControl>
What I'd really like is to include some default attributes and values
in the default tag. I tried changing the ToolboxData attribute, which
is currently:
[ToolboxData("<{0}:MyControl runat=server></{0}:MyControl>")]
to
[ToolboxData("<{0}:MyControl runat=server SomeProp='SomeValue'></
{0}:MyControl>")]
But all that happened then is that the text in the aspx source was
created without an ID attribute.
I've tried setting the DefaultValue attribute of 'SomeProp', and even
changing it so it always returns a value:
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("DefaultPropValue")]
[Localizable(true)]
public string SomeProp
{
get
{
String s = (String)ViewState["SomeProp"];
return ((s == null) ? "DefaultPropValue" : s);
}
set
{
ViewState["SomeProp"] = value;
}
}
Despite this, the aspx tags are still created without extra
attributes.
Clearly this is possible, and I'm doing something wrong, but I'm
damned if I can figure out what...
Thanks in advance,
Andy