473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Trying to get DropDownList to fire a Javascript function

Hi all...

I am trying to do a simple thing and maybe am missing something elementary.
I have created a Javascript function at the top of a page which is meant to
enable editing of an HTML input textbox when the user makes a selection from
the DropDownList control. Since there is no OnClick event I have tried using
OnSelectedIndexChanged or OnTextChanged such as OnTextChanged ="ckCat()"
with ckCat being the javascript function name. I have purposely set
AutoPostback="false" to make sure that wasn't the problem. I have also
tried using the syntax OnTextChanged ="javascript:ckCat()" to no avail.
It's pretty easy to do in classic ASP, but I am trying to get accustomed to
the .NET way of doing things.

Does anyone know what I am missing? I am thinking there must be a way to
enable clientside handling of a DropDownList event, especially with
AutoPostback turned off. I'm just drawing a blank right now.

Thanks to all for any input...

Apr 27 '07 #1
3 12230
John,
You could add this to your Page_Load event on your codebehind:
cboList.Attributes.Add("onchange", "ckCat();");
--
Page Brooks
www.explosivedog.com
"John Kotuby" <jo***@powerlist.comwrote in message
news:OF*************@TK2MSFTNGP06.phx.gbl...
Hi all...

I am trying to do a simple thing and maybe am missing something
elementary. I have created a Javascript function at the top of a page
which is meant to enable editing of an HTML input textbox when the user
makes a selection from the DropDownList control. Since there is no OnClick
event I have tried using OnSelectedIndexChanged or OnTextChanged such as
OnTextChanged ="ckCat()" with ckCat being the javascript function name. I
have purposely set AutoPostback="false" to make sure that wasn't the
problem. I have also tried using the syntax OnTextChanged
="javascript:ckCat()" to no avail. It's pretty easy to do in classic ASP,
but I am trying to get accustomed to the .NET way of doing things.

Does anyone know what I am missing? I am thinking there must be a way to
enable clientside handling of a DropDownList event, especially with
AutoPostback turned off. I'm just drawing a blank right now.

Thanks to all for any input...

Apr 27 '07 #2
Thanks Page,

I was trying to figure out a way to add onclick event but the onchange is
what I really want. How does one determine which events/attributes are
"allowed" for a particular ASP control and that the control will respond as
expected? I an guessing that because the onchange attribute is allowed for
the HTML <selecttag which accomplishes the same action it would be
allowed.

Of course (light bulb just went on) the DropDownList control must render as
an HTML <selectand therefore the OnChange event would be perfectly legal
at the browser. Yes I was missing an important but simple concept. Sometimes
I get so focused on the Server side processing of Server Controls I lose
site of the fact that they are simply rendered as standard HTML.

I would love to find a chart to post by my desk "<Server Control-- renders
as -- <HTML Tags>". Almost as important a reminder as the Page Event life
cycle on the server side.

Thanks again Page for making this task easier...
"Page Brooks" <NO**************@gmail.comwrote in message
news:eX**************@TK2MSFTNGP04.phx.gbl...
John,
You could add this to your Page_Load event on your codebehind:
cboList.Attributes.Add("onchange", "ckCat();");
--
Page Brooks
www.explosivedog.com
"John Kotuby" <jo***@powerlist.comwrote in message
news:OF*************@TK2MSFTNGP06.phx.gbl...
>Hi all...

I am trying to do a simple thing and maybe am missing something
elementary. I have created a Javascript function at the top of a page
which is meant to enable editing of an HTML input textbox when the user
makes a selection from the DropDownList control. Since there is no
OnClick event I have tried using OnSelectedIndexChanged or OnTextChanged
such as OnTextChanged ="ckCat()" with ckCat being the javascript function
name. I have purposely set AutoPostback="false" to make sure that wasn't
the problem. I have also tried using the syntax OnTextChanged
="javascript:ckCat()" to no avail. It's pretty easy to do in classic
ASP, but I am trying to get accustomed to the .NET way of doing things.

Does anyone know what I am missing? I am thinking there must be a way to
enable clientside handling of a DropDownList event, especially with
AutoPostback turned off. I'm just drawing a blank right now.

Thanks to all for any input...




Apr 28 '07 #3
John,
No problem. You are right, each Server Control ultimately renders as one
ore more client-side HTML controls. Just give it some time to sink in,
after working with the controls for a while you shouldn't have any trouble
remembering them. Just keep in mind, that some controls may render
differently depending on which properties are selected on the server-side.
Take the TextBox control for example. Changing the TextMode property of the
TextBox Server control to multiline will cause ASP.NET to render the control
as a TEXTAREA control rather than an <INPUT type="text" ...control.

--
Page Brooks
www.explosivedog.com
"John Kotuby" <jo***@powerlist.comwrote in message
news:Og****************@TK2MSFTNGP06.phx.gbl...
Thanks Page,

I was trying to figure out a way to add onclick event but the onchange is
what I really want. How does one determine which events/attributes are
"allowed" for a particular ASP control and that the control will respond
as expected? I an guessing that because the onchange attribute is allowed
for the HTML <selecttag which accomplishes the same action it would be
allowed.

Of course (light bulb just went on) the DropDownList control must render
as an HTML <selectand therefore the OnChange event would be perfectly
legal at the browser. Yes I was missing an important but simple concept.
Sometimes I get so focused on the Server side processing of Server
Controls I lose site of the fact that they are simply rendered as standard
HTML.

I would love to find a chart to post by my desk "<Server Control--
renders as -- <HTML Tags>". Almost as important a reminder as the Page
Event life cycle on the server side.

Thanks again Page for making this task easier...
"Page Brooks" <NO**************@gmail.comwrote in message
news:eX**************@TK2MSFTNGP04.phx.gbl...
>John,
You could add this to your Page_Load event on your codebehind:
cboList.Attributes.Add("onchange", "ckCat();");
--
Page Brooks
www.explosivedog.com
"John Kotuby" <jo***@powerlist.comwrote in message
news:OF*************@TK2MSFTNGP06.phx.gbl...
>>Hi all...

I am trying to do a simple thing and maybe am missing something
elementary. I have created a Javascript function at the top of a page
which is meant to enable editing of an HTML input textbox when the user
makes a selection from the DropDownList control. Since there is no
OnClick event I have tried using OnSelectedIndexChanged or OnTextChanged
such as OnTextChanged ="ckCat()" with ckCat being the javascript
function name. I have purposely set AutoPostback="false" to make sure
that wasn't the problem. I have also tried using the syntax
OnTextChanged ="javascript:ckCat()" to no avail. It's pretty easy to do
in classic ASP, but I am trying to get accustomed to the .NET way of
doing things.

Does anyone know what I am missing? I am thinking there must be a way to
enable clientside handling of a DropDownList event, especially with
AutoPostback turned off. I'm just drawing a blank right now.

Thanks to all for any input...





Apr 30 '07 #4

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

Similar topics

2
by: Brennon Arnold | last post by:
I have a problem that I figured would be relatively common, but have been unable to find any information on it as of yet. I have a page that contains two DropDownList controls, with the second...
2
by: jm | last post by:
I have datagrid. On this datagrid there is a button and a dropdownlist. When I press the button, I want the selectedIndex of the dropdownlist. There is a button and a dropdownlist for each...
2
by: MBhat | last post by:
Hello, I have a dropdownlist server control.On selectedIndexChange I do some functionality. In addtion to this I need to check for something else. To do this I have to use javascript function to...
7
by: Daniel | last post by:
Is there any other way can override this event, like javascript onchange added to the attribute of this dropdownlist? Thanks
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
4
by: David | last post by:
Hi all, I am doing this in a web page... I have a dropdownlist that autopostback. This sets me a filter criteria for items to display in a datalist. In the datalist, I have edit...
3
by: Iain | last post by:
Hi All I have 2 DropDownList boxes on a page. The first (id= "Operation") is populated on PageLoad with the contents of a database table. The second id="WorkStations" will not be populated...
6
by: w1688 | last post by:
Hi All, I had asp page using Visual studio 2005 to develop. I had a dropdownlist box with more than hundred items list. I am looking a function which allow user to type on dropdownlist box and the...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.