N
neil S via DotNetMonster.com
I have a custom control with a textbox and dropdown list. The dropdown
list is hidden and acts as a data source for the textbox. When the user
enters text in the textbox, an onKeyup event is fired and retrieves the
first value from the dropdown list equal to that entered, and fills the
text box. Essentially, the two together are acting as a type
ahead/autocomplete thingy. All this works fine. Here's my problem: I
wanted to expose the textbox onChange event to the host page (remember,
this is a custom control). This didn't work because, I assume, the textbox
was being changed behind the scenes using javascript and therefore, the
onChange event wasn't firing. So I looked for a workaround and thought I
could get away with an onBlur event from the textbox. I can get the onBlur
event to postback but unfortunately, I can't seem to expose it to the host
page.
Here's some sample attempts on my part that might help if your so inclined
to help me solve this (I'd worship you forever!).
Dim tBox As New TextBox
The following:
AddHandler tBox.TextChanged, AddressOf tBox_Change
creates an onchange event along with all the right stuff (ie: __doPostBack()
; <span id="customControl1" onchange="tBox_Changed"><span <input
name="customControl1:_ctl1" type="text" onchange="__doPostBack
('customControl1$_ctl1','')" language="javascript" />)
But I don't want this. I want an onBlur. Unfortunately, there isn't an
AddHandler tBox.onBlur, AddressOf tBox_Blur or anything remotely like this.
Then I tried the following:
tBox.Attributes.Add("onBlur", "__doPostBack('" & Me.UniqueID & "$_" &
tBox.id & "',''); ") but it didn't expose the event on the host page.
Nor did the following:
tBox.Attributes.Add("onBlur", Page.GetPostBackEventReference(tBox))
This seemed to automatically create an onChange for me but I didn't want
this:
tBox.AutoPostBack = True
I've tried numerous other combinations but haven't hit on the right one yet.
Any help would be greatly appreciated.
Thanks
list is hidden and acts as a data source for the textbox. When the user
enters text in the textbox, an onKeyup event is fired and retrieves the
first value from the dropdown list equal to that entered, and fills the
text box. Essentially, the two together are acting as a type
ahead/autocomplete thingy. All this works fine. Here's my problem: I
wanted to expose the textbox onChange event to the host page (remember,
this is a custom control). This didn't work because, I assume, the textbox
was being changed behind the scenes using javascript and therefore, the
onChange event wasn't firing. So I looked for a workaround and thought I
could get away with an onBlur event from the textbox. I can get the onBlur
event to postback but unfortunately, I can't seem to expose it to the host
page.
Here's some sample attempts on my part that might help if your so inclined
to help me solve this (I'd worship you forever!).
Dim tBox As New TextBox
The following:
AddHandler tBox.TextChanged, AddressOf tBox_Change
creates an onchange event along with all the right stuff (ie: __doPostBack()
; <span id="customControl1" onchange="tBox_Changed"><span <input
name="customControl1:_ctl1" type="text" onchange="__doPostBack
('customControl1$_ctl1','')" language="javascript" />)
But I don't want this. I want an onBlur. Unfortunately, there isn't an
AddHandler tBox.onBlur, AddressOf tBox_Blur or anything remotely like this.
Then I tried the following:
tBox.Attributes.Add("onBlur", "__doPostBack('" & Me.UniqueID & "$_" &
tBox.id & "',''); ") but it didn't expose the event on the host page.
Nor did the following:
tBox.Attributes.Add("onBlur", Page.GetPostBackEventReference(tBox))
This seemed to automatically create an onChange for me but I didn't want
this:
tBox.AutoPostBack = True
I've tried numerous other combinations but haven't hit on the right one yet.
Any help would be greatly appreciated.
Thanks