473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

checkbox autopostback not firing

I have a datagrid with checkboxes and I am able check/uncheck the
checkboxes to update a database by calling my oncheckchanged function.
I would like to add popup asking the users if they are sure they want
to proceed.

I have written a javascript function named confirm_duplicate and it
works as expected - it checks/unchecks checkboxes depending on user
response.

The problem is when I use the javascript alert the checkbox
autopostback does not occurr and my oncheckchanged function is never
called. Can anyone provide any clues of what I need to do? Thanks

asp code:

function confirm_duplicate()
{
if (confirm("Are you sure you want to \nchange this
selection?")==true)
return true;
else
return false;
}

<ItemTemplate>
<asp:CheckBox id=chk runat="server" AutoPostBack="true"
onCheckedChanged="oncheckchanged"
Checked='<%#IsCheck(DataBinder.EvalContainer.DataI tem, "Duplicate"))
%>'>
</asp:CheckBox>
</ItemTemplate>

C# code:
void myDataGrid_ItemCreated(object
sender,System.Web.UI.WebControls.DataGridItemEvent Args e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
CheckBox _chk = (CheckBox)e.Item.FindControl("chk");
_chk.Attributes.Add("onclick", "return confirm_duplicate();");
}
}
public void oncheckchanged(object source, System.EventArgs e)
{
code to update database
}

protected bool IsCheck(object objInc)
{
helper code to check/uncheck datagrid column on page load
}

Aug 14 '06 #1
0 1590

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
2
by: alien2_51 | last post by:
Can some one tell me why the onclick is firing twice for the radion button and checkbox controls...? <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Testing.aspx.vb"...
3
by: Jack Turnbull | last post by:
Hi, I have a Checkbox in a Repeater set to AutoPostBack = true. I have pointed OnCheckedChanged to a Sub but it doesn't fire. If I move the checkbox out of the Repeater it fires! Any ideas? Thanks
3
by: DotNetJunkies User | last post by:
Hi, I have a checkbox control programmatically created for each row in the datagrid but CheckedChanged event not firing when state of the checkbox changes. I use the following code to...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
2
by: dilip.movva | last post by:
Hi, In the ItemDataBound of my datagrid I am creating a checkbox dynamically. I have the eventhandler defined for CheckedChanged of the check box. The event is not firing. The grid is bound in the...
4
by: tshad | last post by:
I use popups periodically to my buttons to prevent actions in my pages. When I tried this with a checkbox: DeclineSSN.Attributes.Add("onClick", "if(!confirm('Declining to enter SSN will...
1
by: pleaseexplaintome | last post by:
I have a datagrid with checkboxes and I can check/uncheck the checkboxes to update a database by calling my oncheckchanged function. I would like to add popup asking the users if they are sure...
3
by: John Mott | last post by:
This is a total ID-10T error, but since its my first attempt I'm missing the obvious. I downloaded the framework, create an AJAX enabled app, added a page, and added an update panel with this: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.