Java script popup dialog box when a check box control is checked. How to do with a check box?

 I have a checkbox named cbxGetInfo. If someone checks the checkbox, I want to a popup dialog box confirming the action that will be done because of the checkbox
 being checked. A few months ago, I used a Java Script popup dialog box for a confirmation on an action being done. Now I need to figure out how to do this for
 when a check box has been checked. Can someone tell me what I am doing wrong. Here is the code I place in my C# code.


 cbxGetInfo.Attributes.Add("onchecked", "javascript:if(confirm('Are you sure you want to delete this record?')== false) return false;");

9/30/2007 10:37:38 PM 93655 articles. 6 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 46
Get it on Google Play
Get it on Apple App Store

Hello AppDevForMe,

I think you are using the wrong event name. Use OnClick in stead of OnChecked.

Jeroen Molenaar.


Jeroen Molenaar.
10/1/2007 8:05:57 AM

cbxGetInfo.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this record?');");


i think it should be..

cbxGetInfo.Attributes.Add("onclick", "test()"); // page load event.. and the function "test" is defined in script tag as..

<script type="text/javascript" language="javascript">
    function test()
        if(document.getElementById('<%=cbxGetInfo.ClientID%>').checked == true)
            return confirm('Are you sure you want to delete this record?');                        

this is because.. we would ask to delete the record only if checkbox value is true / checked... other wise not....

we can also use RegisterClientScriptBlock instead of writing script in inline code as i have done above...

Good Luck./. 

[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
10/1/2007 8:43:20 AM

Similar Artilces:

Check Box changes other check boxes
Hi, I have a question concerning changing a check box without doing a post back on the page. I would like to do something like this: Public Sub checkAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles checkAll.CheckedChanged If checkAll.Checked = False Then    checkVisio.Checked = True    checkPPT.Checked = True    checkRawArt.Checked = True    checkFlatArt.Checked = True Else    checkVisio.Checked = False    checkPPT.Checked = False    checkRawArt.Checked = F...

Checking Check Boxes
I've got a page that edits user permissions that I'm porting from PHP. When the page loads, I need the site to load a checkbox list with the name of the various items and the IDs as the value. This is easy. However, I also need it to check off the selected items. This information is stored in a seperate database table. Using a JOIN I can write a query that will return the page id, the page name, and the permissions of the user fairly easily. However, I don't know what attribute to set in order for appropriate boxes to be checked when the page loads. I'm posting this in the PHP m...

How to check how many check boxes are checked in the gridview
I am trying to make a javascript client fucntion to restrict no more then two rows could be selectedI have following in the itemtemplate of the gridview [although it is telerik control but same technique should be applied] <radG:GridTemplateColumn UniqueName="chkCheck">                    <HeaderStyle  HorizontalAlign="Right" />                    <HeaderTempla...

how to check if a check box created in runtime checked or not?
I have a webform that have mutiple collectios of check boxes created on run time ( database driven) what is the best way to loop between them and get which ones has been checked by a user and save the results back to the database below a portion of my code. i am adding the checkbox to cell table which added to a row, then to a table, finlally the table added to a place holderwhile (drProfileList.Read()) {HtmlTableRow tr = new HtmlTableRow(); HtmlTableCell tc = new HtmlTableCell();CheckBox chkbox = new CheckBox(); chkbox.ID = drProfileList["RoleID"].ToString();chkbox.T...

Check All Check Box While Check Header CheckBox
 hello...I have two grid on same page...both grid contains header checkbox and item checkbox i want that if use check header checkbox then all item check box checked,i have javascript for this functinality but problem is that when i click on header check box of first grid then checkbox of second grid also checked that i dnt want i want to perform this operation on one grid at one time.i have attache my script also...plz help me....thanks<script type="text/javascript">        function SelectAll(ID)      &nbs...

Get the datafield of check boxes that checked in datagrid(with java script)?
i have a datagrid that have some checkboxes. i introduce the check boxes in datagrid like: how can i get the datafield(like id) of check boxes that checked, from database(with java script) thanks. Why do you want do do it with javascript? It's not that easy ... You could just do it in code behind on a button click event. Then if you already have the id of the row in a column, you can fetch it like described in the following article: If you have any comments, questions, remarks ... please let us know RegardsWimPlease remember to click ...

List box control with check boxes?
hi, can any one help me to find is there any option for check boxes in List box using Not with built in controls. But if you can do it with html then you can create your own server list box control which displays checkbox in listbox. or simply use repeater to render that on browser.Jigar Desai-----------------------Do not forget to "Mark as Answer" on the post that helped you....

How to check for the existing user in database and using custom validator how to check check box is checked or not?
Hi Friends, For Registration page i want to check if that user already exist in database or not? and i also have to check if user have check the checkbox for i agree then only he will be able to complete registration. here i am sending my design. and all validation i have done all validation except these two.<html xmlns="" > <head id="Head1" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PRIZE MLS</title><link href="css/style.c...

How to add check box in list box control
Hi how to add check box control in list box dynamically ( data loaded from db) or any other controls in 2005 Regards, Sabarish. Here is your solution Cheers,Nihar ranjan NayakMicrosoft certified   Hi, Refer the below link:  Hope this will help you....

check to see if check box is checked onclientclick button event.
i have a check box similiar to "please check the box if you have read and understand what i placed there".  Right now i have the submit button doing a postback and checking to see if the checkbox is checked. great but inefficient.  I would like to use the onclientclick to check if the checkbox is checked and if not alert the user to check the box.  Thank you in advance and your help is appreciated.  I am very new to this javascript stuff so please spare me.  I am keeping the code inside my aspx file, not in codebehind. Jake You should look at using a validatio...

Check Box checked to delete
I have Checkbox in datagrid, the problem is I can't configure my delete button so that when pressed it will delete the row of data that were checked. Do I have to put in my delete button in the item template or I can simply drag and put it in the page? I tried drag and drop the button in the page but I can't access the datagrid checkbox to determine wether is checked or not.  I would appreciate if anyone can provide me solutions and code as well (I'm a newbie need detail steps) Thanks here's my code <asp:GridView ID="GridView1" r...

list box with check box
how to place check boxes in list box use this existing forum Please tell m how to populate checklistbox how to add elements in that its urgent To add an item to a listbox during runtime, you can use the following syntax: List1.AddItem Item, Index Hi, You can also use the following code bind the CheckBoxList at run time public partial class checkboxInListBox : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        ArrayList values = new Arra...

Value, When I Check the Check Box
Is there any way when I select the check Box, it update the total value but Page should not be post Back.That means i want to select the corresponding value at the time of Check Box Click.Thanks     Do u mean, u want post back page after click on check box You can use the aspnet ajax updatepanel control and wrap your controls within that panel so that it will not refresh everytime you will check a checkbox and fired the event... another thing is you can use JavaScript and handle the stuff at the Client Side since you dont want to post back on the server...more info ab...

How to Check Check Box In GridView
I have One DropDown Bind With Some Procedure Table.And One GridView Bind Same Procedure Table and Grid View Have Templte Column,In Template Column Have Check Box.Both The ddl and GridView Working Properly. The Problem is there I want If Any Procedur Select in Dropdown then This Procedure Is Also check ijn GridView.     Atul try this javascript on the select onchange of dropdownlist  DgItemCount=4;//total gridview row count var CheckCount = 0; for ( i=2;i<DgItemCount + 2 ;i++) { if(document.getElementById("gridview1_ctl" + i + "_youritemname&qu...

Web resources about - Java script popup dialog box when a check box control is checked. How to do with a check box? -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Now you can control your GoPro Camera from Apple Watch
One of the nicest features of the GoPro camera is the ability to control it using the iPhone app. With the GoPro App , you can easily control ...

Control a car's features with a glance? Not science fiction
Filed under: Emerging Technologies , Infotainment , Technology Press a button to change your car's climate controls? Turn a knob to view your ...

Arizona leaders welcome 'Leave No Child Behind' successor, less federal control Arizona leaders welcome 'Leave No Child Behind' successor, less federal control The Senate gave final approval ...

FTC and healthcare cost control
... Pennsylvania, and lead to reduced quality and higher health care costs for the area’s employers and residents….the merged entity would control ...

Google seems more determined than ever to take control of Android
... to ad money. However, Google grabbed the lion’s share of the smartphone market by giving Android away. That means it lost the ability to control ...

How to control your iPhone by just tilting your head
... the best sight, hearing, or motor functions to still use iOS to its fullest capabilities — but they can also be used to customize your controls. ...

Fox Presents Ben Stein As An Awesome, Stupendous Gun Control Genius
Fox News host Neil Cavuto was super-impressed with “great writer and thinker” Ben Stein's opposition to gun control. “The problem is not gun ...

White House: We’re Not Going To Wait Until Something Happens To Pass Gun Control
Reporter: 'Where any of the recent mass shooters on the no-fly list?' Earnest: 'Not that I'm aware of'

The NFL Should Seize Control Of The Cleveland Browns
Drew Magary’s Thursday Afternoon NFL Dick Joke Jamboroo runs every Thursday during the NFL season. Email Drew here . Read more...

Resources last updated: 12/11/2015 12:24:40 PM