473,406 Members | 2,713 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,406 software developers and data experts.

how can i add client side javascript to a web user control?

hi,

i have a web user control that i wish to add some client-side
javascript to. something like this: onChange="javascript:DoSomething();"

how can i add this and where do i need to add it? do i need to somehow
add it to my .ascx file?

i tried to add it into my HTML like below but it does not
get rendered when i do View|Source.

<uc1:TypeAheadComboBox id="cboPaymentTerm"
onChange="javascript:DoSomething();" runat="server"></uc1:TypeAheadComboBox>

i also tried to add it to my .ascx file like below but this gives errors:

Protected bdBody As HtmlGenericControl
Public Sub New()
bdBody.Attributes("onChange") = "window.alert('changed');"
End Sub

any advice appreciated.

thanks.


Nov 17 '05 #1
2 17808
You can do it that way:
cboPaymentTerm.Attributes.Add("onchange", "DoSomething();")

"Tariq Ahmad" <ta*********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP11.phx.gbl...
hi,

i have a web user control that i wish to add some client-side
javascript to. something like this: onChange="javascript:DoSomething();"

how can i add this and where do i need to add it? do i need to somehow
add it to my .ascx file?

i tried to add it into my HTML like below but it does not
get rendered when i do View|Source.

<uc1:TypeAheadComboBox id="cboPaymentTerm"
onChange="javascript:DoSomething();" runat="server"></uc1:TypeAheadComboBox>
i also tried to add it to my .ascx file like below but this gives errors:

Protected bdBody As HtmlGenericControl
Public Sub New()
bdBody.Attributes("onChange") = "window.alert('changed');"
End Sub

any advice appreciated.

thanks.


Nov 17 '05 #2


works a charm ... thanks a lot!

(note for anyone else wanting to do this:
your control must expose its Attributes collection. if it doesnt
u will still be able to do Attributes.Add but it will not work as
desired).

"Anatoly" <an******@gilat.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
You can do it that way:
cboPaymentTerm.Attributes.Add("onchange", "DoSomething();")

"Tariq Ahmad" <ta*********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP11.phx.gbl...
hi,

i have a web user control that i wish to add some client-side
javascript to. something like this: onChange="javascript:DoSomething();"

how can i add this and where do i need to add it? do i need to somehow
add it to my .ascx file?

i tried to add it into my HTML like below but it does not
get rendered when i do View|Source.

<uc1:TypeAheadComboBox id="cboPaymentTerm"
onChange="javascript:DoSomething();"

runat="server"></uc1:TypeAheadComboBox>

i also tried to add it to my .ascx file like below but this gives errors:
Protected bdBody As HtmlGenericControl
Public Sub New()
bdBody.Attributes("onChange") = "window.alert('changed');"
End Sub

any advice appreciated.

thanks.



Nov 17 '05 #3

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

Similar topics

2
by: YARG | last post by:
I've got a load of client side javascript that I want to use with the wizard control. The idea being that when the user clicks on the "Next" button then it will validate just that page. I don't...
4
by: Matt Jensen | last post by:
Howdy all Hopefully I can explain my problem straightforwardly. In it's simplest explanation, what I want to do is have a hyperlink that, when clicked, executes some client side JavaScript and...
7
by: Alex Maghen | last post by:
I have some client-side JavaScript that I want to run whenever a pulldown <SELECT> is changes on th client. I'm trying to do this as follows... <select id="MyPulldown"...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
6
by: anoop | last post by:
Hello, I want to implement client side MD5 hash for Login Control using Javascript. how do I implement this. Thank you
1
by: Keithb | last post by:
I have some client-side javascript for that I use for dhtml stuff such as hiding div tags based on user menu selections, etc. I need a way to maintain the state of javascript variables across...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, imagine this for a moment if you will: i have a row in a gridview that when it is in edit mode there is a column that contains a dropdownlist and 2nd column that contains a user control....
8
by: MAX2006 | last post by:
Hi, I am doing some client side javascipt work. I have a handler for window.onUnload event and within the code; I need to know the name of the asp.net button caused the postback. How can I do...
2
by: goscottie | last post by:
I need to find a way to either 1. run and check all Validation controls (in my case one CompareValidator) and run client side javascript function. In this case I'll use <asp:Button>. So if all...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.