簡體   English   中英

如何將UserControl.ascx的代碼隱藏類放在另一個庫中

[英]How to put Code-Behind Class of UserControl.ascx in another Library

我有一個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示例項目

在您的示例中,刪除UserControl1.ascx的繼承。

在usercontrol1.ascx.cs中,取消注釋所有代碼。

更改

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

public partial class UserControl1 : otherClassInAnotherProject

最后,otherClassInAnotherProject應該繼承自System.Web.UI.UserControl

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM