我们使用以下的方法来做:首先先定义自定义控件 *.ascx

public class yourcontrol : System.Web.UI.UserControl

{

    pravite string _Mytext

    public string Mytext

    {

         get{ ... }

         set{ ... }

    }

}

    

在调用它的 .aspx文件中:

首先要注册自定义控件,注册的语句要写到页面的上方(属于页面指令的位置。   )

<%@ Register TagPrefix="uc1" TagName="yourcontrol" Src="yourcontrol.ascx"%>

然后在aspx文件中使用:

<uc1:yourcontrol ID="yourControl1" runat="server"></前缀:控件标签名>

使用自定义控件的属性在 .aspx.cs文件中:

protected yourControl yourcontrol1;

yourcontrol1.Mytext = "";

相关文章:

  • 2022-02-13
  • 2022-12-23
  • 2022-01-17
  • 2021-05-20
  • 2023-04-07
  • 2021-06-09
猜你喜欢
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-08-28
相关资源
相似解决方案