By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

OnChange

P: n/a
Does anyone know how to trap SelectedIndexChanged event on the client side
for the following control?
http://www.metabuilders.com/Tools/ComboBox.aspx

I have tried MyComboBox.Attributes.Add("OnChange", "return
IndexChanged();");
but OnChange event never fires
Thanks

Peter
Aug 2 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
zEE

try onClick instead on onChange

Aug 2 '06 #2

P: n/a
zEE

try onClick instead on onChange

Aug 2 '06 #3

P: n/a
zEE

try onClick instead on onChange

Aug 2 '06 #4

P: n/a
Peter,

You need to know what html is produced for the control. Browser option "View
Source" will give you an idea. Then you will need to figure out how to get
to the exact html element you want to attach an event to.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Peter" <pc*****@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Does anyone know how to trap SelectedIndexChanged event on the client side
for the following control?
http://www.metabuilders.com/Tools/ComboBox.aspx

I have tried MyComboBox.Attributes.Add("OnChange", "return
IndexChanged();");
but OnChange event never fires
Thanks

Peter

Aug 2 '06 #5

P: n/a
Hello Peter,

I've just downloaded the "combobox" control and performed some test, I
think the combobox control is composite of two built-in controls:
a dropdownlist(html <selectelement) and a textbox(<input type="text"
...../>). And there has added many additional client-side scripts to
manipulate the composite control.

As for the select change event of the combobox control, it is processed
through the following path:

1. user change the <selectelement's item

2 #1 will trigger the select item's onchange client event,

3 the event handler(defined by the control) in #2 will call the textbox's
onchange event handler(defined ) by the control.

So there is no direct client-side "onchange" event for the combobox
control. since the source code is available, I suggest you consider
customizing it and add an additional property like "onClientChange" and let
the develper specify client-sdie onchange handler. Also, you need to modify
the original code which register the client-side onchange handlers(for the
<selectand textbox) and add your own client-side handler functions( a
placeholder).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 2 '06 #6

P: n/a

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:I5**************@TK2MSFTNGXA01.phx.gbl...
Hello Peter,

I've just downloaded the "combobox" control and performed some test, I
think the combobox control is composite of two built-in controls:
a dropdownlist(html <selectelement) and a textbox(<input type="text"
..../>). And there has added many additional client-side scripts to
manipulate the composite control.

As for the select change event of the combobox control, it is processed
through the following path:

1. user change the <selectelement's item

2 #1 will trigger the select item's onchange client event,

3 the event handler(defined by the control) in #2 will call the textbox's
onchange event handler(defined ) by the control.

So there is no direct client-side "onchange" event for the combobox
control. since the source code is available, I suggest you consider
customizing it and add an additional property like "onClientChange" and
let
the develper specify client-sdie onchange handler. Also, you need to
modify
the original code which register the client-side onchange handlers(for the
<selectand textbox) and add your own client-side handler functions( a
placeholder).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take
approximately
2 business days

as the support professional working with you may need further
investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
Thanks for your help

I have one question:

In your answer you said

"Also, you need to modify
the original code which register the client-side onchange handlers(for the
<selectand textbox) and add your own client-side handler functions( a
placeholder)."

Can you tell me where is the code that registers the client-side handlers
(What's the name of the method) ?
Thanks
Peter
Aug 2 '06 #7

P: n/a
Hi Peter,

You can lookup the control methods in the "ComboBox.cs" file, I found the
following methos which are helpful to you:

protected override void OnPreRender(System.EventArgs e) {
========================
Most of the scripts (defined in template file) are registered into page in
this function. You can find those scripts and do some customization if you
want.
protected override void AddAttributesToRender( HtmlTextWriter writer ) {
=========================
In this method, the "onchange" client-side event handler is added into the
html <selecttag, you can consider modify it to involve some of your own
script functions in the "onchange" attribue value.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 3 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.