C# 嵌套页中的异常查找控件(asp.net)
我曾经为我的网页开发过一些东西,但现在不行了 我想在我的aspx.cs页面中加载一个控件(ul),但它引发了一个异常 我的html如下所示:C# 嵌套页中的异常查找控件(asp.net),c#,html,asp.net,code-behind,C#,Html,Asp.net,Code Behind,我曾经为我的网页开发过一些东西,但现在不行了 我想在我的aspx.cs页面中加载一个控件(ul),但它引发了一个异常 我的html如下所示: <ul class="offer-list offer-small list-content" id="latestOffers" runat="server"> <li> base {System.Web.UI.HtmlControls.HtmlContainerControl} = {Inne
<ul class="offer-list offer-small list-content" id="latestOffers" runat="server">
<li>
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'}
这是在我的页面加载方法中
我得到了这样的东西:
<ul class="offer-list offer-small list-content" id="latestOffers" runat="server">
<li>
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()
,然后在那里运行此代码。我已经这样做了。没用。我创建了一个方法并从page load方法调用它。