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

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top