R
rn5a
Consider the following user control which resides in Address.ascx:
<script runat="server">
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
Public Property Country() As String
Get
Country = txtCountry.Text
End Get
Set(ByVal value As String)
txtCountry.Text = value
End Set
End Property
</script>
<asp:TextBox ID="txtAddress" runat="server"/>
<asp:TextBox ID="txtCountry" runat="server"/>
This is how I am using the user control in a ASPX page:
<%@ Register TagPrefix="UC" TagName="UAddress" Src="Address.ascx" %>
<script runat="server">
Sub CopyAddress(obj As Object, ea As EventArgs)
..........
..........
End Sub
</script>
<form runat="server">
<UC:UAddress ID="ud" runat="server">
<asp:CheckBox ID="chkAddress" OnCheckedChanged="CopyAddress"
AutoPostBack="true" Text="Copy Address" runat="server"/>
</form>
The above ASPX page will render the 2 TextBoxes (using the user
control) & a CheckBox. Note that when the CheckBox is checked/unchecked
by the user, the sub named 'CopyAddress' gets executed.
Now I want the 2 TextBoxes to also execute the 'CopyAddress' sub using
the OnTextChanged event of the 2 TextBoxes but since the 2 TextBoxes
actually reside in the user control, how do I fire the OnTextChanged
event handler of the 2 TextBoxes so that the 'CopyAddress' sub gets
executed?
<script runat="server">
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
Public Property Country() As String
Get
Country = txtCountry.Text
End Get
Set(ByVal value As String)
txtCountry.Text = value
End Set
End Property
</script>
<asp:TextBox ID="txtAddress" runat="server"/>
<asp:TextBox ID="txtCountry" runat="server"/>
This is how I am using the user control in a ASPX page:
<%@ Register TagPrefix="UC" TagName="UAddress" Src="Address.ascx" %>
<script runat="server">
Sub CopyAddress(obj As Object, ea As EventArgs)
..........
..........
End Sub
</script>
<form runat="server">
<UC:UAddress ID="ud" runat="server">
<asp:CheckBox ID="chkAddress" OnCheckedChanged="CopyAddress"
AutoPostBack="true" Text="Copy Address" runat="server"/>
</form>
The above ASPX page will render the 2 TextBoxes (using the user
control) & a CheckBox. Note that when the CheckBox is checked/unchecked
by the user, the sub named 'CopyAddress' gets executed.
Now I want the 2 TextBoxes to also execute the 'CopyAddress' sub using
the OnTextChanged event of the 2 TextBoxes but since the 2 TextBoxes
actually reside in the user control, how do I fire the OnTextChanged
event handler of the 2 TextBoxes so that the 'CopyAddress' sub gets
executed?