[英]View and aspx.cs
I have a list in the code behind page pages.aspx.cs. 我在页面pages.aspx.cs后面的代码中有一个列表。 How to send this list to the view ie, profile.cshtml?
如何将此列表发送到视图即profile.cshtml? I'm using web forms and MVC together.
我正在一起使用Web窗体和MVC。 I have a list in .aspx, how do I pass it to a controller so that I can use that list in the view.?
我在.aspx中有一个列表,如何将其传递给控制器,以便可以在视图中使用该列表? This is the list in pages.aspx.cs
这是pages.aspx.cs中的列表
List sites = new List(); 列出网站=新的List();
if (Guid.TryParse(SiteID.SelectedValue, out siteId))
{
sites = ServiceFactory<IOrganizationService>
.Return( ( svc, ctx ) => svc.SitesForPostalCode( ctx, PostalCode.Text ) )
.Where(s => s.Guid == siteId).ToList();
}
Why didn't use session or cookie? 为什么不使用会话或cookie? And why didn't you call this method in controller or view?
为什么不在控制器或视图中调用此方法? Are you manipulating list in aspx page?
您正在操纵aspx页面中的列表吗?
I got the solution for this: In .aspx: Session["toList"]=sites 我得到了解决方案:在.aspx中:Session [“ toList”] = sites
In the controller: var locationList = (List)Session["toList"]; 在控制器中:var locationList =(List)Session [“ toList”];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.