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

Flag TabSelecting

0 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Davi asked on 11 Oct 2012, 09:57 PM
Hello, I have a RadTabStrip
This screen calls default.asp
It contains a button that calls the registration screen
This registration screen I have to put a message if the user clicks a tab, "you lost data"
I tried using the function OnClientTabSelecting
But I have to make sure that the User is in the registration screen, and not in default.aps
I tried to use session to store the value, but I noticed that javascript does not work
Would any idea to help me

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
    <link href="../css/SGTWebStyles.css" rel="stylesheet" type="text/css" />
    <telerik:RadCodeBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            var isTabClicked = "false";    

            function OnClientTabSelecting(sender, args) {
                isTabClicked = "false";
                var cadastre = '<%=Session("cadastre")%>';
                if (cadastre == true) {
                    if (isTabClicked == "false") {
                        //cancel the action 
                        //get the tab which is clicked 
                        var tab = args.get_tab();

                        function CallBackFn(arg) {
                            if (arg) {
                                isTabClicked = "true";
                        //ask the user for confirmation                
                        radconfirm("Os dados informados serão perdidos, deseja continuar?", CallBackFn);
            function OnClientTabSelected() {
                //reset the isTabClicked variable
                isTabClicked = "false";
<body onload="window.history.forward();" class="BODY">
    <form runat="server" id="mainForm" method="post">   
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <telerik:RadWindowManager ID="RadWindowManager" runat="server" EnableShadow="true">
    <asp:UpdatePanel ID="UpdatePanelProjeto" runat="server" RenderMode="Inline">
            <div class="DivTab">
                <telerik:RadTabStrip ID="RadTabStripProjeto" runat="server" MultiPageID="RadMultiPageProjeto"
                    SelectedIndex="2" Align="Justify" ReorderTabsOnSelect="True" Width="600px" OnClientTabSelected="RadTabStripProjeto_TabSelected">
                        <telerik:RadTab Text="Projetos Cadastrados" runat="server" Value="Cadastro">
                        <telerik:RadTab Text="Função" Value="Função">
                        <telerik:RadTab Text="Locais de Alocação" Value="Locais de Alocação" Selected="True">
                        <telerik:RadTab Text="Equipe do Projeto" Value="Equipe do Projeto">
                <telerik:RadMultiPage ID="RadMultiPageProjeto" runat="server" SelectedIndex="2" Height="100%"
                    <telerik:RadPageView ID="RadPageViewProjetosCadastrados" runat="server" Height="100%">
                    <telerik:RadPageView ID="RadPageViewFuncao" runat="server" Height="100%" Width="100%">
                    <telerik:RadPageView ID="RadPageViewLocaisAlocacao" runat="server" Height="100%">
                    <telerik:RadPageView ID="RadPageViewEquipeProjeto" runat="server" Height="100%">

Code Behind
Imports Telerik.Web.UI
Partial Class projeto_Principal
    Inherits System.Web.UI.Page
    Dim cSinonimos As New ClassSGT.cSinonimos
    Dim vCadastro As String

#Region "Eventos "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Page.Title = "Dextera"
            If (Not IsNothing(Session("NOME"))) AndAlso (Session("NOME").ToString() <> String.Empty) Then
                ScriptManager.RegisterStartupScript(Me, Me.GetType(), "blockTabPaste", "if (top.location.pathname != '" & Request.ApplicationPath & "/Principal.aspx') {top.location = '" & Request.ApplicationPath & Application.Item("vDirecionaURLDireta") & "';}", True)
                'RadTabStripProjeto.SelectedTab.PageView.ContentUrl = "../projeto/Default.aspx"

                If ClassSGT.cSession.aplicaPermissoesAbas("Projetos", RadTabStripProjeto, Session("NOME").ToString()) Then
                    RadTabStripProjeto_TabClick(RadTabStripProjeto, New RadTabStripEventArgs(RadTabStripProjeto.SelectedTab))
                End If
                ScriptManager.RegisterStartupScript(Me, Me.GetType(), "loggin", Application.Item("vDirecionaLogin"), True)
            End If
        End If
    End Sub
#End Region

    Protected Sub RadTabStripProjeto_TabClick(sender As Object, e As Telerik.Web.UI.RadTabStripEventArgs) Handles RadTabStripProjeto.TabClick
        If e.Tab.PageView.ID = "RadPageViewProjetosCadastrados" Then
            e.Tab.PageView.ContentUrl = "../projeto/Default.aspx"
        ElseIf e.Tab.PageView.ID = "RadPageViewFuncao" Then          
                 e.Tab.PageView.ContentUrl = "../projeto/Funcao.aspx"          
        ElseIf e.Tab.PageView.ID = "RadPageViewLocaisAlocacao" Then
            e.Tab.PageView.ContentUrl = "../projeto/LocalAlocacao.aspx"
        ElseIf e.Tab.PageView.ID = "RadPageViewEquipeProjeto" Then
            e.Tab.PageView.ContentUrl = "../projeto/EquipeProjeto.aspx"
        End If
    End Sub
End Class

Button in ../projeto/Default.aspx"
Protected Sub btnNovo_Click(sender As Object, e As System.EventArgs) Handles btnNovo.Click
            lblError.Text = ""
            Session("cadastre") = True
        Catch ex As Exception
            lblError.Text = ex.Message
        End Try
    End Sub

Please help me, I'm desperate, excuse the English because I'm from Brazil and do not have much knowledge

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question