我的问题很简单 - 我创建了Web用户控制模块,它无法看到他的代码隐藏。该模块的主要目的是在现场左侧创建一组类别。
它的CategoryList.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CategoryList.ascx.cs"
Inherits="MyWebSite.Pages.CategoryList" MasterPageFile="~/Pages/Store.Master"%>
<%= CreateHome %>
<% foreach (string category in GetCategories()) {
Response.Write(CreateLinkHtml(category));
}%>
它的CategoryList.ascx.cs
public partial class CategoryList : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected IEnumerable<string> GetCategories()
{
return new Repository().GetGoods()
.Select(p => p.Category)
.Distinct()
.OrderBy(x => x);
}
protected string CreateHomeLinkHtml()
{
string path = RouteTable.Routes.GetVirtualPath(null, null).VirtualPath;
return string.Format("<a href='{0}'>Головна</a>", path);
}
protected string CreateLinkHtml(string category)
{
string path = RouteTable.Routes.GetVirtualPath(null, null,
new RouteValueDictionary() { { "category", category },
{"page", "1"} }).VirtualPath;
return string.Format("<a href='{0}'>{1}</a>",
path, category);
}
}
}
有什么想法有什么不妥吗?