Hello,
I have a MVC ViewPage with a ListView control on it:
<asp:ListView ID="CarsListView" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>
Then I want to fill the ListView in the page_load event handler of the codebehind-page:
public partial class Thumbs : ViewPage<CarsViewData>
{
protected void Page_Load(object sender, EventArgs e)
{
CarsListView.DataSource = CarsViewData.MyCarsList;
CarsListView.DataBind();
}
}
I get a compilation error on the first and second line of "Page_Load", because the compiler doesn't find the "CarListView" Object:
"The name 'CarsListView' does not exist in the current context". The same problem exists with every asp Control, e.g. an <asp:button>. None of them can be addressed in the code behind file.
What am I doing wrong? I think my example should work when I look at the "Rendering Approach 2: Using Server Side Controls" part of ScottGu's Blog Post: http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx
Second problem:
What is also strange is that when I want to use the HtmlHelper-Objcet "Hmtl" it is null. So for example this code
public partial class Thumbs : ViewPage<CarsViewData>
{
protected void Page_Load(object sender, EventArgs e)
{
Html.ActionLink(....);
}
}
throws a runtime exception because Html is null.
Mybe I have a corrupt installation?
I have installed the VS 2008 Team suite trial. In fact I did a lot of installing these days, so I don't remember if I have installed the ASP.NET 3.5 Extensions CTP manually or if it was shipped with the trial version.
I am using a reference to the MVCToolkit.
Thanks for your hints,
Hannes