Last post Jul 29, 2008 07:55 AM by bgs264
Jul 25, 2008 01:29 AM|bosboss|LINK
I need a custom server control which contains one TextBox and one RadioButtonList. I need to define a OnValueChanged event on custom server control which can capture the TextChanged event of TextBox OR SelectedIndexChanged event of RadioButtonListj, so
that I can get the Text value of TextBox OR SelectedIndex value of RadioButtonList. Then I can use that value to continue more functions in OnValueChanged event. Can anybody show me how to implement that? Some examples or codes would be greatly appreciated!
Jul 25, 2008 02:44 AM|imran_khan|LINK
Can anybody show me how to implement that? Some examples or codes would be greatly appreciated!
I created TellAFriend Custom Control. This helps you. Visit
Jul 29, 2008 07:55 AM|bgs264|LINK
You need to create a custom event which you can raise. You can then handle your custom event whenever it gets fired.
For example, create a custom event "SelectedValueChanged".
Then, create some handlers in your control to handle the TextChanged of the textbox and SelectedValueChanged of the RadiobuttonList. Make both of these handlers raise your custom event.
Something like this- it compiles but I have not tested it.
Public Class TestControl
' All rendering, etc, omitted for clarity.
Private _TextBox As TextBox
Private _RadioButtonList As RadioButtonList
Public Event SelectedValueChanged(ByVal sender As Object, ByVal e As EventArgs, ByVal NewValue As String)
Private Sub TextboxTextChangedHandler(ByVal sender As Object, ByVal e As EventArgs)
RaiseEvent SelectedValueChanged(sender, e, _TextBox.Text)
Private Sub RadiobuttonListChangedHandler(ByVal sender As Object, ByVal e As EventArgs)
RaiseEvent SelectedValueChanged(sender, e, _RadioButtonList.SelectedIndex.ToString())
Public Sub New()
' Wire up handlers
AddHandler _TextBox.TextChanged, AddressOf TextboxTextChangedHandler
AddHandler _RadioButtonList.SelectedIndexChanged, AddressOf RadiobuttonListChangedHandler
Let me know how you go on.