There are 2 ways to pass an ASP. NET custom control:
How to ① fields
Define a field in the. Ascx.cs of the custom control, and then pass in the parameter in the Page_Load method of the calling page.
such as setting the field public in a custom control string pageid= "";
Passing in parameters in the Page_Load of the calling page
cbzbmsx.pageid= ' 1 ';
How to ② Properties
Define a property in the. Ascx.cs of the custom control, and then set the property when the control is used.
Setting properties in Custom controls
private string _type;
public string Type
{
get {return _type;}
set {_type= value;}
}
Set properties on Use <uc1:searbzxx id= "CBZBMSX" runat= "Server" type= "2" ></uc1:SearBzxx>
Comparison between the two methods: ① there is a certain flaw, one interface can only use this custom control once; ② there is no problem in ①
ASP. NET user Custom control pass-through parameter