I've subclassed DropDownList
to add functionality specific to my application:
public class MyDropDownList : DropDownList
{
...
}
... then referenced it in Web.Config
, which is where I figure things start to go wrong:
<pages theme="Main">
<controls>
<add tagPrefix="bob" tagName="MyDropDownList" src="~/Components/MyDropDownList.cs" />
</controls>
</pages>
my reference to it does not work:
<tr><td>Category</td>
<td><bob:MyDropDownList runat="server" ID="Category"... />
and my best clue is the complier error message:
"The file 'src' is not a valid [sic] here because it doesn't expose a type."
I figure I'm misapplying knowledge of how to create a Web User Control here. What I want to be able to do is refer to this control on an ASP.NET page just like I would the parent DropDownList
. Refactoring back into a Web User Control that contains a DropDownList
is not desirable, because I want to apply a RequiredFieldValidator
to it.
<pages theme="Main">
<controls>
<add tagPrefix="bob" namespace="MyProject" assembly="MyProject" />
</controls>
</pages>
That should do the trick.
@Joops answer saved me.
What I did differently was to register the namespace at the top of my page because I didn't need it everywhere.
ie.
<%@ Register TagPrefix="myTagPrefix" Namespace="MySolution.MyProject.Foo.Bar"
Assembly="MySolution.MyProject" %>
cheers Joop!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With