I used the user controls in 2.0 today and found that using user controls programmatically is completely different from that in 1.X.
1. First, declare a reference in the header of the Page you want to use.
as follows:
<%@ Reference Control="../Controls/AlbumEditor.ascx" %>
2. In the code behind, you can find the class reference of this control from the "ASP" space, but you need to give an example.
-_-! I don’t understand why the designer did this. It’s not as intuitive as 1.1.
as follows:
ASP.Controls_AlbumEditor albumediror = (ASP.Controls_AlbumEditor)LoadControl("../Controls/AlbumEditor.ascx");
albumediror.EditAlbumID=e.CommandArgument.ToString();
This is a relatively complete quote.
The advantage compared to 1.X should be that the classes generated by custom user controls will not affect development.
Personally, I feel that such a strongly typed reference is a bit troublesome! -_-!!
Writing code is not fun enough!