我叫Default.aspx頁的自定義用戶控件:在默認傳遞值從頁用戶控制
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;
}
}
}
:
<myPrefix:myTagName ID="category" runat="server" />
自定義用戶控件背後的代碼.aspx.cs代碼,我想設置這個變量的值:
this.articleCategory.value = this.currentArticle.Category.ToString();
我在這最後一行得到這個錯誤的「價值」:
「System.Web.UI.UserControl」不 包含「值」和 沒有擴展方法「值」接受 類型的第一參數「System.Web.UI.UserControl」的定義可以 (是否缺少using 指令或程序集引用?)
所有我見過的演示似乎表明,這應該工作。我錯過了什麼嗎?
實際上喬納斯的答案更可能 – Porco 2011-04-01 19:24:51