|
今天需要完成的功能是aspx向ascx傳值,因為需要提高ascx的重用性,這樣做最好不過了。 查了好久,最終發(fā)現(xiàn)一個簡單的方法: 1,在aspx頁面注冊新建的ascx控件: <%@ Register TagPrefix="uc" TagName="VCS" Src="~/ASCX/Show.ascx" %>_Created by o07-csy 2,在需要引用的位置引用此控件 <uc:VCS ID="VisitCounts" runat="server" _Count="DZTS" />_Created by o07-csy 注意此處的"_Count='DZTS'"這部分,此方法來自于ascx.cs中 3,在ascx.cs中鍵入以下代碼: protected string Count; public string _Count { get { return Count; }_Created by o07-csy set { Count = value; } } |
|
|