先添件组件,然后在HTML中注册一下
<%@ 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.
<%@ 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.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货