您的位置:首页 > 编程语言 > ASP

在aspx文件中调用ascx用户自定义控件的属性

2011-06-18 08:22 267 查看
我们使用以下的方法来做:首先先定义自定义控件 *.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 = "";

来自:/article/5853960.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐