我有一个 UserControl.ascx 并希望此 ascx 使用(引用)另一个库(项目) 中的代码隐藏。所以在 @control
指令中,我执行以下操作
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="..\CodeBehinds\ucBehind1.cs" %>
但是当运行页面时我看到了错误
Parser Error Message: Cannot use a leading .. to exit above the top directory.
有什么办法可以实现吗?
最佳答案
在您的示例中,删除继承自 UserControl1.ascx
在 usercontrol1.ascx.cs 中,取消注释所有代码。
改变
public partial class UserControl1 : System.Web.UI.UserControl
到
public partial class UserControl1 : otherClassInAnotherProject
otherClassInAnotherProject 最终应该继承自 System.Web.UI.UserControl
关于c# - 如何将 UserControl.ascx 的代码隐藏类放入另一个库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13139043/