Confirm Message without Postback

3 posts, 1 answers
  1. Brygom
    Brygom avatar
    15 posts
    Member since:
    May 2009

    Posted 10 Dec 2009 Link to this post

    Hello! I hope can help me ..
    I need to show a confirmation message before the
    Deleting a row, I tried this:
    <telerik:RadGrid ID="rgSucursales" runat="server" AllowPaging="True" AllowSorting="True" 
                            GridLines="None" onneeddatasource="rgSucursales_NeedDataSource"  
                            VirtualItemCount="1" onitemcommand="rgSucursales_ItemCommand"  
                            onitemdatabound="rgSucursales_ItemDataBound" > 
                            <PagerStyle FirstPageToolTip="Primera Página" /> 
                            <MasterTableView PageSize="5"
                                <Columns>  
                                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Editar"  
                                        ImageUrl="img/editar.png" Text="Editar Cuenta" UniqueName="column"
                                    </telerik:GridButtonColumn> 
                                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Eliminar"  
                                        ImageUrl="img/eliminar.png" Text="Eliminar Cuenta" UniqueName="EliminarColumna"  > 
                                    </telerik:GridButtonColumn> 
                                </Columns> 
                            </MasterTableView> 
                            <ClientSettings EnableAlternatingItems="False"
                                <Selecting AllowRowSelect="False" /> 
                                <ClientMessages PagerTooltipFormatString="Página &lt;strong&gt;{0}&lt;/strong&gt; de &lt;strong&gt;{1}&lt;/strong&gt;" /> 
                            </ClientSettings> 
                        </telerik:RadGrid> 

    protected void rgSucursales_ItemCommand(object source, GridCommandEventArgs e) 
            { 
                string cmd = e.CommandName.ToString(); 
                 
                 
                if (cmd.Equals("Editar")) 
                {                 
                    Session["BANEDIT"] = item["Codigo"].Text; 
                    rwSucursales.NavigateUrl = "~/OperCat.aspx"
                    rwSucursales.Visible = true
     
                } 
                else if (cmd.Equals("Eliminar")) 
                { 
                    GridDataItem item = (GridDataItem)e.Item; 
                    ImageButton deleteBtn = (ImageButton)item["EliminarColumna"].Controls[0]; 
                    deleteBtn.Attributes.Add("OnClick""if(!confirm('¿Está seguro que desea Realizar la Venta?')){return false;};"); 
                                     
                    var codigoEliminar = item["Codigo"].Text; 
     
                    if (_dbase.DeleteQuery("Delete From tb where id_Bs=" + codigoEliminar).Equals("Ok")) 
                    { 
                        //Row deleted 
                                                                       "AlertSucess('#effect','¡La Cuenta ha sido eliminada!');"true); 
     
                         
                    } 
                    else 
                    { 
                        //Problem in query 
                    } 
     
                } 
                
            } 





    But the problem is that the first time I press the
    button deletes the row, when I delete another row
    It works and shows me the message.

    That way I can show the confirmation message without
    do a postback?

    Thanks for your help!

    Sincerly Briayan!

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Dec 2009 Link to this post

    Hello Briayan,

    A better approach would be to use the ConfirmText property of the GridButtonColumn, for which you would not have to implement custom code and this will not cause a postback! Here's an example:
    aspx:
    <telerik:GridButtonColumn ButtonType="ImageButton" ConfirmText="¿Está seguro que desea Realizar la Venta?" 
     CommandName="Eliminar" ImageUrl="Images/UnSelected.gif" Text="Eliminar Cuenta" UniqueName="EliminarColumna">  
    </telerik:GridButtonColumn> 

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brygom
    Brygom avatar
    15 posts
    Member since:
    May 2009

    Posted 01 Jan 2010 Link to this post

    Thank you for the reply, this is my solution!..
Back to Top