2

我有一个 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.

有没有办法实现它?

GitHub 示例项目

4

1 回答 1

0

在您的示例中,从 UserControl1.ascx 中删除继承

在 usercontrol1.ascx.cs 中,取消注释所有代码。

改变

public partial class UserControl1 : System.Web.UI.UserControl

public partial class UserControl1 : otherClassInAnotherProject

otherClassInAnotherProject 最终应该继承自 System.Web.UI.UserControl

于 2012-10-30T13:09:10.197 回答