пользователяasp.net MVC пользовательский элемент управления Проблема
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
using (MvcApplication1.Models.EgovtDataContext _model = new MvcApplication1.Models.EgovtDataContext())
{
%>
<% foreach(var md in MvcApplication1.Models.) { %>
<% if (md.ParentId == 0)
{ %>
<% } %>
<% } %>
<%} %>
FeatureRepository Класс
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Models
{
public class FeaturesRepository
{
EgovtDataContext db = new EgovtDataContext();
public IEnumerable<Feature> GetAllFeatures()
{
List<Feature> Features = new List<Feature>();
Feature feature = new Feature();
var AllParentFeatures = FeaturesByParentId(0);
foreach (Feature frParentCategory in AllParentFeatures)
{
feature.int_FeatureId = frParentCategory.int_FeatureId;
feature.vcr_FeaturesName = frParentCategory.vcr_FeaturesName;
feature.int_ParentId = frParentCategory.int_ParentId;
Features.Add(feature);
var AllChildFeaturesofthatParent = FeaturesByParentId(frParentCategory.int_FeatureId);
int AllChildFeaturesofthatParentCount = AllChildFeaturesofthatParent.Count();
foreach (Feature frChildCategory in AllChildFeaturesofthatParent)
{
feature.int_FeatureId = frParentCategory.int_FeatureId;
feature.vcr_FeaturesName = frParentCategory.vcr_FeaturesName;
feature.int_ParentId = frParentCategory.int_ParentId;
Features.Add(feature);
}
}
return Features;
}
}
}
1) Является ли это правильно сделали публичные IEnumerable GetAllFeatures() в приведенном выше методе? И метод правильно написал? 2) Я хочу вызвать метод GetAllFeatures в элементе управления выше? как бы я это сделал? 3) Пользовательский контроллер должен быть создан в общей папке? Для чего предназначена общая папка?
контроллеры пользователей должны быть созданы в общей папке? – maztt
Вы можете создать контроллер в папке контроллера – Pinu