This is a migrated thread and some comments may be shown as answers.

Adding delete confirmation to a RadTab

5 Answers 113 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Warnestam
Top achievements
Rank 1
Warnestam asked on 12 Aug 2008, 06:21 PM
Is there a way to adding a delete confirmation to a RadTab.

The following lines does not work;
Telerik.Web.UI.RadTab tab = new RadTab("Ta bort");  
tab.Attributes.Add("OnClick", "return confirm('Delete this record?');");  
tsFunctionMenu1.Tabs.Add(tab);  
             
The confirmation dialogue is displayed, but a postback is always made.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Aug 2008, 11:53 AM
Hi,

I tried this on my end and it is working as expected. Have you set the AutoPostBack property of the RadTabStrip to true? Try setting it to false and see whether it is making a postback.

ASPX:
<telerik:RadTabStrip ID="RadTabStrip1" AutoPostBack="false"  runat="server" OnPreRender="RadTabStrip1_PreRender"
        </telerik:RadTabStrip> 

CS:
Telerik.Web.UI.RadTab tab = new RadTab("Ta bort"); 
        tab.Attributes.Add("OnClick", "return confirm('Delete this record?');"); 
        RadTabStrip1.Tabs.Add(tab); 


Thanks
Shinu.
0
Warnestam
Top achievements
Rank 1
answered on 14 Aug 2008, 10:56 AM
Are you sure you got it to work? I tried your suggestion without success. In following code I created a small sample that shows the problem. Remember that we are using RadTabStrip to enable functions for the user and for some of those functions the user must confirm the action on the client (without doing a postback). Traditionally we would like to use the confirm daialog in the broweser.

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
    </telerik:RadAjaxManager> 
    <br /> 
    Testing delete confirmation on RadTabStrip. In this case I have to RadTabStrips,  
    one for selecting the view and lets the user select and perform an action  
    <br /> 
    <telerik:RadAjaxPanel ID="rapMain" runat="server">  
        <div> 
            <telerik:RadTabStrip ID="tsMenu" runat="server" SkinID="PageMenuSkin" SelectedIndex="0" 
                MultiPageID="rmpMain" AutoPostBack="true">  
                <Tabs> 
                    <telerik:RadTab runat="server" ID="rtStatus" Selected="True" PageViewID="rpvStatus" 
                        Text="Functions">  
                    </telerik:RadTab> 
                    <telerik:RadTab runat="server" ID="rtMap" PageViewID="rpvMap" Text="Map">  
                    </telerik:RadTab> 
                </Tabs> 
            </telerik:RadTabStrip> 
            <telerik:RadMultiPage ID="rmpMain" runat="server" SelectedIndex="0">  
                <telerik:RadPageView ID="rpvStatus" runat="server">  
                    A view with some functions...  
                    <br /> 
                    <telerik:RadTabStrip ID="rtsFunctions" runat="server" AutoPostBack="False" OnTabClick="rtsFunctions_TabClick" 
                        SelectedIndex="-1">  
                    </telerik:RadTabStrip> 
                    <br /> 
                </telerik:RadPageView> 
                <telerik:RadPageView ID="rpvMap" runat="server" Height="39px" Width="695px">  
                    Another view...  
                    <br /> 
                </telerik:RadPageView> 
            </telerik:RadMultiPage> 
        </div> 
        <br /> 
        <hr /> 
        <asp:Label ID="lblCounter" runat="server" Text="0" /> 
        <br /> 
        <asp:Label ID="lblText" runat="server" EnableViewState="false" /> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 

CS:
using System;  
using System.Configuration;  
using System.Data;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
 
using Telerik.Web.UI;  
 
public partial class _Default : System.Web.UI.Page   
{  
 
    private const string COMMAND_DELETE = "del";  
    private const string COMMAND_ADD = "add";  
 
 
    protected void Page_Init(object sender, EventArgs e)  
    {  
        lblText.Text = "";  
        InitFunctions();  
    }  
      
    protected void Page_Load(object sender, EventArgs e)  
    {  
        lblCounter.Text = (Convert.ToInt32(lblCounter.Text) + 1).ToString();  
        lblText.Text += "PageLoad<br>";  
    }  
    protected void rtsFunctions_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)  
    {  
        // Do the function  
        if (e.Tab.Value.Equals(COMMAND_ADD))  
        {  
            lblText.Text+="Add<br>";  
        }  
        else if (e.Tab.Value.Equals(COMMAND_DELETE))  
        {  
            lblText.Text+="Delete<br>";  
        }  
        else  
        {  
            lblText.Text+="Unknown tab<br>";  
        }  
 
        rtsFunctions.SelectedIndex = -1;  
    }  
 
    private void InitFunctions()  
    {  
        lblText.Text+="InitFunctions<br>";  
        RadTab tabDelete = new RadTab("Delete", COMMAND_DELETE);  
        RadTab tabAdd = new RadTab("Add", COMMAND_ADD);  
 
        tabDelete.Attributes.Add("OnClick","return confirm('Delete this record?');");  
 
        rtsFunctions.Tabs.Add(tabAdd);  
        rtsFunctions.Tabs.Add(tabDelete);  
    }  
 
}  
 
0
Warnestam
Top achievements
Rank 1
answered on 18 Aug 2008, 02:45 PM
I've been searching for a solution for this problem over the weekend and I would be grateful if anyone could show me a working solution.

Thanks

Robert
0
Veselin Vasilev
Telerik team
answered on 18 Aug 2008, 03:36 PM
Hi Warnestam,

Can't you subscribe to the OnClientTabSelecting client-side event and cancel it as shown in the help article?

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Warnestam
Top achievements
Rank 1
answered on 18 Aug 2008, 04:16 PM
Thanks, that worked perfectly!

/Robert
Tags
TabStrip
Asked by
Warnestam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Warnestam
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or