Checkbox and Java Script Function

  • Thread starter =?ISO-8859-1?Q?Andr=E9_Nobre?=
  • Start date
?

=?ISO-8859-1?Q?Andr=E9_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é
 
G

Guest

<asp:checkbox id="testcheck" runat="server">

Code behind:
in page load event handler
testcheck.attributes.add("onclick","youJSFunction()");

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

Yunus Emre ALPÖZEN [MCAD.NET]

My advice u to create an inherited control. override render method and add
your custom logic.
 
?

=?ISO-8859-1?Q?Andr=E9_Nobre?=

Thanks for the answers,
I'll user an inherited control, it looks better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top