嵌套页 (asp.net) 中的异常查找控件



我正在为我的网页开发一些工作的东西,但现在没有了。

我想在我的 aspx.cs 页面中加载一个控件 (ul),但它引发了异常。

我的 html 是这样的:

<ul class="offer-list offer-small list-content" id="latestOffers" runat="server">
                <li>

我的代码隐藏:

 ullo = HtmlGenericControl) this.Master.FindControl("ContentPage").FindControl("latestOffers");

这是我的页面加载方法。

我得到这样的东西:

base {System.Web.UI.HtmlControls.HtmlContainerControl} 
= {InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)
(((System.Web.UI.HtmlControls.HtmlGenericControl)(ulLatestOffers)))).InnerText
' threw an exception of type 'System.Web.HttpException'}

这是有效的,但不再有效。

怎么了?你们能帮我吗?

ullo = HtmlGenericControl) this.Master.FindControl("ContentPage").FindControl("latestOffers");

我猜这条线位于您的构造函数中。添加一个新方法,假设InitControl()并在那里运行此代码。

最新更新