P
pleaseexplaintome
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 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.DataItem, "Duplicate"))
%>'>
</asp:CheckBox>
</ItemTemplate>
C# code:
void myDataGrid_ItemCreated(object
sender,System.Web.UI.WebControls.DataGridItemEventArgs 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
}
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.DataItem, "Duplicate"))
%>'>
</asp:CheckBox>
</ItemTemplate>
C# code:
void myDataGrid_ItemCreated(object
sender,System.Web.UI.WebControls.DataGridItemEventArgs 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
}