ASP.NET Controls and Common Elements

Can I use ASP.NET controls with generics? I have never seen this and would like to distinguish some controls on a page by type, that is: DateTime vs int

example:

public class MyGenericTextBox<T>: TextBox
{
public MyGenericTextBox<T>() {... }
}
+3
source share
3 answers

This can be done using a special hack, for example, the one I used in this article:

Typed Relay in ASP.NET

However, I would not recommend doing this just for convenience in simple cases, as the result would be more complex than what you are trying to improve.

+3
source

- Visual Studio intellisense, . - , , , .

+3

This will probably work if you only use the control from the code. I doubt that it can be represented in markup or in a designer.

+2
source

Source: https://habr.com/ru/post/1702158/


All Articles