ASP. NET user Custom control pass-through parameter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.