Newbie: JavaScript validation on <Asp:CheckBox click

R

Rob

It might be a simple question.
I am very new to ASP.Net 2, and stuck with a problem.
How can I execute a client side JavaScript function on CheckBox click.
I am able to execute function at server, But I don't know how to validate at
client side before going to server.


This code is within a GridView
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Bind("OpenConnection") %> '
Enabled="True"
OnCheckedChanged="OpenConnection_Clicked" AutoPostBack="True" />
</ItemTemplate>

When I put onClick="Javascript:FunctionName" within the tag, it says:
Validation (ASP.Net): Attribute'onclick' is not a valid attribute for
element 'CheckBox'.

Please help me.
I'll appreciate your help.

Thanks, Rob
 
G

Guest

It looks like button would better suit the purpose - usually when you want to
perform an action (as you do with AutoPostBack="true") a button or a link is
the way to go, and you could use OnClientClick property to inject your
javascript

HTH
 

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