【发布时间】:2013-05-21 01:36:52
【问题描述】:
我有一个在 Default.aspx 页面中调用的自定义用户控件:
<myPrefix:myTagName ID="category" runat="server" />
自定义用户控件的代码:
namespace WebApplication3.inc.controls {
public partial class myTag : System.Web.UI.UserControl {
public String id;
public String name;
public String value;
public Hashtable attributes;
protected void Page_Load(object sender, EventArgs e) {
if (this.id != null)
this.attributes["id"] = this.id;
if (this.name != null)
this.attributes["name"] = this.name;
if (this.value != null)
this.attributes["value"] = this.value;
}
}
}
在 Default.aspx.cs 代码中,我想设置这个标签的值:
this.articleCategory.value = this.currentArticle.Category.ToString();
我在最后一行的“值”处收到此错误:
'System.Web.UI.UserControl' 没有 包含“价值”的定义和 没有扩展方法“值”接受 类型的第一个参数 'System.Web.UI.UserControl' 可能是 找到(您是否缺少使用 指令还是程序集引用?)
我看到的所有演示似乎都表明这应该有效。我错过了什么吗?
【问题讨论】:
标签: c# parameter-passing user-controls