473,657 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox and Java Script Function

Hi all...

How can I call a java script function when user clicks on my
asp:checkbox control? It's obvious that server control events doesn't
work, because it runs on server.. So, how can i assign a javascript
function to run where there is an onClick event on asp:checkbox?

Thanks,
André
Nov 19 '05 #1
3 1972
<asp:checkbox id="testcheck" runat="server">

Code behind:
in page load event handler
testcheck.attri butes.add("oncl ick","youJSFunc tion()");

write in JS
function youJSFunction()
{
alert("my check box")
}

"André Nobre" wrote:
Hi all...

How can I call a java script function when user clicks on my
asp:checkbox control? It's obvious that server control events doesn't
work, because it runs on server.. So, how can i assign a javascript
function to run where there is an onClick event on asp:checkbox?

Thanks,
André

Nov 19 '05 #2
My advice u to create an inherited control. override render method and add
your custom logic.

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"André Nobre" <no@spam.com> wrote in message
news:ex******** ******@tk2msftn gp13.phx.gbl...
Hi all...

How can I call a java script function when user clicks on my asp:checkbox
control? It's obvious that server control events doesn't work, because it
runs on server.. So, how can i assign a javascript function to run where
there is an onClick event on asp:checkbox?

Thanks,
André

Nov 19 '05 #3
Thanks for the answers,
I'll user an inherited control, it looks better.

--
André Nobre
Hi all...

How can I call a java script function when user clicks on my
asp:checkbox control? It's obvious that server control events doesn't
work, because it runs on server.. So, how can i assign a javascript
function to run where there is an onClick event on asp:checkbox?

Thanks,
André

Nov 19 '05 #4

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

Similar topics

5
3664
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.... 2. after population there should be validation in checkboxlist..... that is if user clicks a button wihout checking any one of them(i.e. at least one shuld be checked) ... alerat message shouls come on the form....... these 2 steps should be...
4
1678
by: Stefan Mueller | last post by:
To following code/script shows me the row number of the checkbox I've just clicked: <form name = "my_form" action = "" method = "post" accept-charset = "iso-8859-1"> <table name = "my_table" border = "1"> <tr> <td> <input type = "checkbox" onClick = "alert('Row 1');"> </td>
4
5343
by: biswaranjan.rath | last post by:
Hi, I've few checkboxes in different rows. After selecting appropriate values, the user should click a button. I wanted to convert those checkbox values to non-editable(or non-editable textboxes), so that user cannot change the value again after the needed functionality(this is in java script) completes. So my problem is that how should i manipulate the page through java script to set the field noneditable. Please suggest.
0
2799
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
10
5195
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named 'CheckAllRows' on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the...
1
7309
by: Phils | last post by:
I have a simple problem but after an afternoon of searching still cant get a solution. I have an asp checkbox on my form that i want to, when checked, enable a textbox. when the checkbox is unchecked the textbox becomes disabled again. i want to use some client side script as i dont want to always post back for such a trivial thing. how would you create a java function to disable the text box when the checkbox is checked and how would...
2
13137
by: nitindutt2005 | last post by:
Hi I have a html file as below. ==================================================================== <html> <head> <td style="background-color:rgb(170, 157, 244);"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
13
26912
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. Regards Ramprakash /*Adminpage.jsp*/ <%@ page language="java" import="java.sql.*"%> <html> <head>...
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8603
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.