在一个.aspx文件中添加下面的代码:

<%=EnabledFileType%>

出现错误提示:

System.Web.HttpException (0x80004005): 
控件包含代码块(即 <% ... %>),因此无法修改控件集合。
在 System.Web.UI.ControlCollection.Add(Control child)

对应的英文错误为:

The Controls collection cannot be modified because the control contains code blocks

解决方法:

改为如下的代码(等号改为井号):

<%#EnabledFileType%>

并在Page_Load中添加如下的代码:

private void Page_Load(object sender, System.EventArgs e)
{   
    this.DataBind();
}

搞定!

相关文章:

  • 2022-01-24
  • 2021-12-13
  • 2021-07-26
  • 2021-09-04
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2021-09-17
  • 2022-02-06
  • 2021-07-31
  • 2021-08-07
相关资源
相似解决方案