我有一个问题,我试图在用户控件“input.ascx”和“output.ascx”之间发送一个字符串,当我有多个用户控件时。
这是父页面的 ASPX:
<uc:Input runat="server" id="Input1" />
<uc:Input runat="server" id="Input2" />
<uc:Output runat="server" id="Output1" />
<uc:Output runat="server" id="Output2" />
用户控制输入 ASCX:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
用户控制输入 VB.net:
Public Shared Event Button1Click(ByVal s As String)
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String = TextBox1.Text
RaiseEvent Button1Click(s)
End Sub
用户控制输出 ASCX:
<%@ Reference Control="~/Input.ascx" %>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
用户控制输出 VB.net:
Public Sub New()
AddHandler UCTestUcInput.Button1Click, AddressOf DisplayText
End Sub
Private Sub DisplayText(ByVal s As String)
Label1.Text = s
End Sub
问题是当我输入任何一个“input.ascx”时,它都会显示在两个“output.ascx”中,而它应该只显示在相应的输出中(如 input1 对应于 output1)。