更新时间:2023-10-19 20:37:40
在你想传递给它的数据的数据类型用户控件创建一个属性,并填充它在你的页面上创建控件。
Create a property on your user control with the datatype of the data you want to pass to it, and populate it in your page on creation of the control.
public class myControl : Control
{
...
public int myIntValue {get; set;}
...
}
在code背后:
myControl ctrl = new myControl();
ctrl.myIntValue = 5;
您还可以在标记做到这一点直接:
You can also do this directly in markup:
<uc1:myControl ID="uc1" runat="server" myIntValue="5" />