2

UserControl.ascx が 1 つあり、この 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 に答える