我剛剛開始一個新項目,我正在發生一些非常奇怪的事情。爲什麼我的Repeater在代碼後面爲空?
ASP.NET 3.5,VS2008。
我試過重建,關閉VS,刪除一切,並再次從svn,但我不明白爲什麼在page_load下面的中繼器爲null。
我知道這將是一個頭頂的時刻。幫幫我?
標記:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GalleryControl.ascx.cs" Inherits="Site.UserControls.GalleryControl" %>
<asp:Repeater ID="rptGalleries" runat="server">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li>wqe</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
代碼背後
public partial class GalleryControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
rptGalleries.DataSource = new[] {1, 2, 3, 4, 5};
rptGalleries.DataBind();
}
}
設計師:
public partial class GalleryControl {
/// <summary>
/// rptGalleries control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rptGalleries;
}
爲什麼我的中繼空? F正在發生什麼?
的參考頁有這樣的:
<ux:GalleryControl runat="server" ID="uxGalleryControl"/>
web.config中有這個(我以前從來沒有這樣做,但我的母版在抱怨找不到另一個用戶控制)。
<add tagPrefix="ux" namespace="Site.UserControls" assembly="Site" />
很奇怪。你有沒有檢查你的.aspx.designer.cs文件的中繼器控制? 也許由於某種原因,設計者並沒有自動生成參考?我見過之前發生過。 – RPM1984 2010-06-10 00:50:06
是的,它在那裏。更新的問題。 – 2010-06-10 00:54:19
我剛剛嘗試創建一個具有相同效果的全新控件。引用它的頁面上有一個DropDownList,這很好。 – 2010-06-10 00:58:48