関連するクラス (usercontrol.cs) ファイルを変更せずにユーザー コントロールのイベントを拡張し、app_code に別のクラスとして追加することは可能ですか? 理由: CMS (Ektron) を使用しているため、usercontrol.cs ファイルにコードを追加できません
コードサンプル:
ユーザー コントロール ascx ファイル
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="Usercontrols_WebUserControl" %>
<asp:Button ID="Button1" runat="server" Text="Click me"
onclick="Button1_Click" />
ユーザー コントロール .cs ファイル
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("clicked the button");
}
したがって、新しいクラスまたはこれを達成するためのその他のオプションを作成して、「Button1_Click」イベントに他のコード (例: Response.Write("clicked needed button");) を追加する必要がありますか?