473,465 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

custom control onblur postback

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
Nov 19 '05 #1
1 5647
Hi, you should have a file with a ascx extenstion for your web control. To
make it visible on a form simply drag it from the solution explorer onto the
form. This is one method, probably several others.

"neil S via DotNetMonster.com" wrote:
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lamont Adams | last post by:
Hi all, I've created numerous custom controls of varying complexity, but I've been on this problem for a day and a half, and I can't figure this mystery out. I hope one of you kind folks can...
0
by: Robert Ladd | last post by:
Hi, I'm trying to disable the asp.net calendar control from a javascript function, but it doesn't disable the doPostBack. To simplify the situation, assume a page with 4 controls. A...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
0
by: Iain | last post by:
Can I apologise for the lengthy nature of this post. The scenario is complicated (though I hope the solution is not!) basically, I've got a custom template control which binds itself to a tree...
5
by: Alan Silver | last post by:
Hello, I have a products page that takes a product ID in the query string. Based on the product details (from a database), the page then loads up one of a number of custom controls, calls a...
2
by: J R M | last post by:
I've developed a custom control (it's basically a drop-down list and then a couple of textboxes to include meta-data for the selection) that I'm embedding into another custom control (the idea is...
0
by: =?Utf-8?B?TWFyayBHaWxrZXM=?= | last post by:
I have designed and written a custom menu like server control. The control inherits from DataBoundControl and implements INamingContainer and IPostBackEventHandler interfaces. The control uses only...
7
by: adiel_g | last post by:
Hello Everyone, I created a custom control. On the CreateChildControls, I added a textbox to the control as follows: // TextBox TextBox txtValue = new TextBox(); txtValue.ID = "txtValue"; ...
0
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have an ajax calender control and when the user clicks off the control I would like to force a postback. It seems like possibly the onblur event may do it, but not sure if you can create a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.