I'm attempting to start using DynamicData functionality in a previously existing website. Basically I'm following this tutorial. When I got to the part about creating the Field Templates I decided I could probably create a new site with the Dynamic Data stuff built in, and then just copy the folder over.
我正在尝试在以前存在的网站中开始使用DynamicData功能。基本上我正在学习本教程。当我开始创建Field模板时,我决定创建一个内置Dynamic Data内容的新站点,然后将文件夹复制过来。
Unfortunately when I do that and try to compile I get the error "Could not load type..." for just about every .ascx file in the DynamicData directory. I named the "new" project the same as the pre-existing site so that the namespace would be the same... but I can't think of what else I could be missing.
不幸的是,当我这样做并尝试编译时,我得到错误“无法加载类型...”几乎所有.ascx文件在DynamicData目录中。我将“新”项目命名为与预先存在的站点相同,以便命名空间相同......但我想不出还有什么我可能会遗漏。
Everything looks ok, except that the *.ascx.Designer.cs files are showing inside the Solution Explorer. I tried deleting one and then copying that file back into just the directory but it didn't work. I'm assuming I need to do something special with those so that Visual studio handles them properly and can compile?
除了* .ascx.Designer.cs文件显示在解决方案资源管理器中之外,一切看起来都不错。我尝试删除一个,然后将该文件复制回目录,但它不起作用。我假设我需要做一些特别的事情,以便Visual Studio正确处理它们并且可以编译?
Here is one of the .aspx files:
这是.aspx文件之一:
<%@ Control Language="C#" CodeBehind="FilterUserControl.ascx.cs" Inherits="EService.FilterUserControl" %>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
EnableViewState="true" ontextchanged="new">
<asp:ListItem Text="All" Value="" />
</asp:DropDownList>
Here is the matching .cs file:
这是匹配的.cs文件:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;
namespace EService
{
public partial class FilterUserControl : System.Web.DynamicData.FilterUserControlBase
{
public event EventHandler SelectedIndexChanged
{
add
{
DropDownList1.SelectedIndexChanged += value;
}
remove
{
DropDownList1.SelectedIndexChanged -= value;
}
}
public override string SelectedValue
{
get
{
return DropDownList1.SelectedValue;
}
}
protected void Page_Init(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PopulateListControl(DropDownList1);
// Set the initial value if there is one
if (!String.IsNullOrEmpty(InitialValue))
DropDownList1.SelectedValue = InitialValue;
}
}
}
}
And here is the .ascx.designer.cs file:
这是.ascx.designer.cs文件:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace EService
{
public partial class FilterUserControl
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
}
}
EDIT: If I create the file in the website, then copy the contents from the temporary site I created it seems to compile just fine. Really have no idea what the issue is here... I tried manually modifying files to match the results of copying and they still wouldn't work unless I actually created them in the site. It's just bizarre...
编辑:如果我在网站上创建文件,然后从我创建的临时网站复制内容似乎编译得很好。真的不知道这里的问题是什么...我尝试手动修改文件以匹配复制的结果,除非我在网站上实际创建它们,否则它们仍然无法工作。这很奇怪......
2 个解决方案
#1
The problem was due to the temporary site creating the <%@ Control > definitions with the CodeBehind property instead of the CodeFile property. For some reason pages in the actual website will only compile when CodeFile is declared...
问题是由于临时站点使用CodeBehind属性而不是CodeFile属性创建<%@ Control>定义。出于某种原因,实际网站中的页面只会在声明CodeFile时编译...
#2
DD will work with Either Website or Web Application. however when copying in from an other project the types need to be the same otherwise it's lot of editing to convert swee my article here Getting Dynamic Data Futures filters working in a File Based Website.
DD将与Either Website或Web Application一起使用。但是当从其他项目中复制时,类型需要相同,否则需要进行大量编辑才能转换我的文章。在基于文件的网站中使用动态数据期望过滤器。
#1
The problem was due to the temporary site creating the <%@ Control > definitions with the CodeBehind property instead of the CodeFile property. For some reason pages in the actual website will only compile when CodeFile is declared...
问题是由于临时站点使用CodeBehind属性而不是CodeFile属性创建<%@ Control>定义。出于某种原因,实际网站中的页面只会在声明CodeFile时编译...
#2
DD will work with Either Website or Web Application. however when copying in from an other project the types need to be the same otherwise it's lot of editing to convert swee my article here Getting Dynamic Data Futures filters working in a File Based Website.
DD将与Either Website或Web Application一起使用。但是当从其他项目中复制时,类型需要相同,否则需要进行大量编辑才能转换我的文章。在基于文件的网站中使用动态数据期望过滤器。