<%@ Register TagPrefix="myCompany" TagName="CarCtl" Src="Car.ascx" %>
[C#]
// Add other code here.
// Binds the car object to the control declared
// in the following code.
myCarCtl.Car = car;
myCarCtl.DataBind();
// Add other code here.
<%-- Control declaration --%>
<myCompany:CarCtl id="myCarCtl" runat="server" />
如果愿意,也可以使用 LoadControl 方法取代 @ Register 指令,如以下代码所示。
[C#]
// Use the LoadControl method.
CarCtl = LoadControl("Car.ascx")
Form.Controls.Add(CarCtl);
// Insert the remainder of the previous code here.
浙公网安备 33010602011771号