Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have a javascript function:

      function confirmerSupprimer()
      {
        var confirm=confimrm("est vous sur de vouloir supprimer ce facturation");
        if(confimrm==false)
          return false;
      }
    </script>

inside a datagrid: i have

<asp:TemplateColumn>
                                <HeaderStyle Width="15%"></HeaderStyle>
                                <ItemTemplate>
                                    <asp:ImageButton id="ibEdit" runat="server" CommandName="update" ImageUrl="./Images/edit.gif" AlternateText="Editer"></asp:ImageButton>
                                    <asp:ImageButton id="ibDelete" runat="server" CommandName="delete" ImageUrl="./Images/del.gif"
                                                            AlternateText="Supprimer" OnClick="confirmerSupprimer();"></asp:ImageButton>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:ImageButton id="ImageButton6" runat="server" CommandName="update" ImageUrl="images/save.gif"
                                        AlternateText="Valider"></asp:ImageButton>

                                    <asp:ImageButton id="ImageButton4" runat="server" CommandName="cancel" ImageUrl="./Images/cancel.gif"
                                        AlternateText="Annuler"></asp:ImageButton>
                                </EditItemTemplate>

Error:

BC30456: 'confirmerSupprimer' not a a member of 'ASP.Facturation_aspx'.

What's the pb

share|improve this question
add comment

1 Answer

This function is declared in JavaScript - your GridView is expecting a method declared in C#—that's why you're getting that error.

If you want to wire this image button up with that JavaScript function, you could add this call to the Attributes collection in your code behind.

<asp:DataGrid OnItemDataBound="yourDataGrid_RowDataBound" 

protected void yourDataGrid_RowDataBound(object sender, DataGridItemEventArgs e)
{
    if (e.Item.ItemType != ListItemType.AlternatingItem && e.Item.ItemType != ListItemType.Item) return;

    ImageButton ib = e.Item.Cells[YourIndex].FindControl("ibDelete") as ImageButton;
    ib.Attributes["onclick"] = "javascript:return confirmerSupprimer()";
}
share|improve this answer
    
how can i add confirmation popup for the user? –  user594166 Dec 7 '11 at 16:04
    
@user594166 - see my edit –  Adam Rackis Dec 7 '11 at 16:07
    
Thanks let me check –  user594166 Dec 7 '11 at 16:09
    
@user594166 - just make sure you add RowDataBound to your Grid to point to this method –  Adam Rackis Dec 7 '11 at 16:10
    
@user594166 - sorry, I see you're using asp.net 1.1 - I updated my code accordingly –  Adam Rackis Dec 7 '11 at 16:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.