Step 1: Put the user control in mylist. ascx, and the control command is:
CopyCode The Code is as follows: <% @ Control Language = "C #" autoeventwireup = "true" codefile = "viewcomment. ascx. cs" inherits = "control_viewcomment" %>
At this time, you already have inherits, And the built-in classname is its name. If not, you must create the classname attribute.
Assume that it has a public property ID.
Step 2: UseCopy codeThe Code is as follows: <% @ reference control = "mylist. ascx" %>
<% @ Page Language = "C #" codefile = "getascx. aspx. cs" inherits = "adentity_getascx" %>
Reference. At this time, the ascx control can be dynamically loaded in the code page getascx. aspx. CS:
Control_viewcomment CTRL = (control_viewcomment) page. loadcontrol ("~ /Control/viewcomment. ascx ");
CTRL. ID = request ["adentityid"];
Base. Controls. Add (CTRL );
In addition:Copy codeThe Code is as follows: <% @ register Assembly = "business" namespace = "business" tagprefix = "my" %>
Complete.