希望這項工作you.For時間是我在用戶控件使用單按鈕控制:
ASCX文件:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="buttonl.ascx.cs"Inherits="Controls_buttonl" %>
<asp:Button ID="Button1" runat="server" Text="Button user control"
onclick="Button1_Click" />
ASCX.cs文件:
protected void Button1_Click(object sender, EventArgs e)
{
if (this.ID == "buttonl1")
{
//perform action according to panel1
}
else if (this.ID == "buttonl2")
{
//perform action according to panel2
}
}
ASPX頁面(母版):
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="99px" Width="224px">
<uc1:buttonl ID="buttonl1" runat="server" />
</asp:Panel>
</div>
<div>
<asp:Panel ID="Panel2" runat="server" Height="97px" Width="222px">
<uc1:buttonl ID="buttonl2" runat="server" />
</asp:Panel>
</div>
</form>
請讓我知道如果仍然無法達到您的目標。
讓我明確一些要點1.您是否使用網絡用戶控件?2.此用戶控件僅包含一個按鈕控件? – Sunny 2013-05-03 07:41:43
我在這裏有點困惑。你怎麼能在2個不同的面板上有相同的按鈕? 你能粘貼你的代碼片段嗎? – 2013-05-03 07:42:35