Toolbar radConfirm

2 posts, 0 answers
  1. Tasnim
    Tasnim avatar
    2 posts
    Member since:
    Sep 2011

    Posted 13 Sep 2011 Link to this post

    hi 
    i use rad confirm in delete button on toolbar .
    confirm work but my code for delete in codbehind not work.!
    pls help

    toolbar:
    <td colspan="3" height="40" valign="top">
         <telerik:RadToolBar ID="RadToolBar1" OnClientButtonClicking="clientButtonClicked" runat="server" dir="rtl" Height="30px" 
             onbuttonclick="RadToolBar1_ButtonClick"  Skin="Office2007" Width="100%">
             <Items>
                 <telerik:RadToolBarButton runat="server" Text="new">
                 </telerik:RadToolBarButton>
                 <telerik:RadToolBarButton runat="server" Text="save">
                 </telerik:RadToolBarButton>
                 <telerik:RadToolBarButton runat="server" Text="edit">
                 </telerik:RadToolBarButton>
                 <telerik:RadToolBarButton runat="server" Text="del" >
                 </telerik:RadToolBarButton>
             </Items>
         </telerik:RadToolBar>

    javascript :
    <script type="text/javascript">
        //<![CDATA[
        var lastClickedItem = null;
        var clickCalledAfterRadconfirm = false;
        function clientButtonClicked(sender, args) {
            if (args.get_item().get_text() == 'Del') {
                if (!clickCalledAfterRadconfirm) {
                    args.set_cancel(true);
                    lastClickedItem = args.get_item();
                    radconfirm('Del؟', confirmCallBackFn, 330, 100, null, 'Tasnim232');
                }
            }
        }
     
         
     
        function confirmCallBackFn(arg) {
            if (args) {
                clickCalledAfterRadconfirm = true;
                lastClickedItem.click();
            }
            else
                clickCalledAfterRadconfirm = false;
            lastClickedItem = null;
        }
     
         
                            //]]>                                                                       
    </script>

    codebehind:
    protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Index == 0)
            {
                T_Tittle.Text = "";
                T_ID.Text = "0";
            }
            else
                if (e.Item.Index == 1)
                {
                    int Opr_ = 0;
                    if ((T_ID.Text == "") | (T_ID.Text == "0"))
                        Opr_ = 1;
                    else
                        Opr_ = 2;
                    Pishraft _Sanj = new Pishraft();
                    BLL_Pishraft _Ins = new BLL_Pishraft();
                    _Sanj.Pishraft_ID = Convert.ToInt32(T_ID.Text);
                    _Sanj.Pishraft_Tittle = T_Tittle.Text;
                    DataTable DT_ = _Ins.Pishraft_Act(_Sanj, Opr_);
                    if (DT_.Rows[0][0].ToString() == "1")
                    {
                        WindowManager_.RadAlert("OK", 330, 100, "Tasnim", "");
                        Grid_.DataBind();
                    }
                    else
                        if (DT_.Rows[0][0].ToString() == "2")
                            WindowManager_.RadAlert("د", 330, 100, "Tasnim", "");
                        else
                            if (DT_.Rows[0][0].ToString() == "-1")
                                WindowManager_.RadAlert("ok", 330, 100, "Tasnim", "");
                }
                else
                    if (e.Item.Index == 2)
                    {
                        Grid__SelectedIndexChanged(sender, e);
                    }
                    else
                        if (e.Item.Index == 3)
                        {
                            if (T_ID.Text != "")
                            {
                                 
     
                                Pishraft _Noe = new Pishraft();
                                BLL_Pishraft _Ins = new BLL_Pishraft();
                                _Noe.Pishraft_ID = Convert.ToInt32(T_ID.Text);
                                _Noe.Pishraft_Tittle = T_Tittle.Text;
                                DataTable DT_N = _Ins.Pishraft_Act(_Noe, 3);
                                if (DT_N.Rows[0][0].ToString() == "1")
                                {
                                    WindowManager_.RadAlert("عت", 330, 100, "Tasnim", "");
                                    Grid_.DataBind();
                                }
                                
     
                        }
     
     
        }
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4712 posts

    Posted 14 Sep 2011 Link to this post

    Hello Tasnim,

    I believe you are following this KB article. Please examine it carefully. The code you provided has errors in the JavaScript which is the most likely reason why you do not get to the code-behind at all. The text of the node was del, while you search for Del and the argument passed to the callback function should be arg, not args in the if statement. You can see this functioning correctly in this video: http://screencast.com/t/jOdzTMSI. Please note that I have commented out the functionality for the code-behind as it is not runnable - i.e. some custom classes and functionality I do not have and they should be taken care of the developer.


    Best wishes,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Back to Top