473,287 Members | 1,613 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,287 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 12226
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.