Trying to get an asp:Checkbox to display an alert when the person clicks it.

M

Mufasa

I have a situation where I need to display an alert when somebody clicks a
check box. I was able to get it to work with a plain <input> but when I try
and do it with an <asp:CheckBox> I can't get the javascript right.

Anybody have any thoughts?

TIA - Jeff.
 
M

marss

I have a situation where I need to display an alert when somebody clicks a
check box. I was able to get it to work with a plain <input> but when I try
and do it with an <asp:CheckBox> I can't get the javascript right.

Anybody have any thoughts?

TIA - Jeff.

<asp:CheckBox ID="CheckBox1" runat="server" ....

Code behind:
protected void Page_Load(object sender, EventArgs e)
{
...
CheckBox1.Attributes.Add("onclick", "alert('clicked');");

Regards,
Mykola
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top