Last post Jan 07, 2009 04:53 AM by DottyWelsh
Jan 06, 2009 12:05 PM|DottyWelsh|LINK
I have a regular Search Page
this has a SearchBar Control on it
The searchbar has a custom DateControl on it
The dateControl contains a TextBox.
The events are raised for the Dropdown list as normal, but because the date fields are not a regular text box, i cannot raise the "TextChanged" event simply on the SearchBar.ascx.vb page.
Does anyone know how i can raise a custom event so that when the text is changed on my DateControl an event is raised on my SearchBar.ascx
Thanks in advance
Jan 06, 2009 01:40 PM|ps2goat|LINK
Declare an event in your usercontrol, and the page you put that usercontrol on will be able to handle it.
// in user control.
Public Event TextChanged(byval sender as object, byval e as EventArgs)
Protected Sub TextBox_TextChanged(byval sender as object, byval e as EventArgs) Handles myTextbox.TextChanged
' me passes this whole usercontrol to the event handler.
' pass whatever you like for sender, but this is usually the best way.
RaiseEvent TextChanged(Me, e)
// in page that the user control is on.
Protected Sub UserControl_TextChanged(bvval sender as object, byval e as EventArgs) Handles myUserControl.TextChanged
'... do code.
Dim myUC as myUserControl = CType(sender, myUserControl)
Jan 07, 2009 04:53 AM|DottyWelsh|LINK
Thank you so much,
That does the trick