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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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
args.set_cancel(true);
//get the tab which is clicked
var tab = args.get_tab();
function CallBackFn(arg) {
if (arg) {
isTabClicked = "true";
tab.click();
}
}
//ask the user for confirmation
radconfirm("Os dados informados serão perdidos, deseja continuar?", CallBackFn);
}
}
}
function OnClientTabSelected() {
//reset the isTabClicked variable
isTabClicked = "false";
}
</script>
</telerik:RadCodeBlock>
</head>
<body onload="window.history.forward();" class="BODY">
<form runat="server" id="mainForm" method="post">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadWindowManager ID="RadWindowManager" runat="server" EnableShadow="true">
</telerik:RadWindowManager>
<asp:UpdatePanel ID="UpdatePanelProjeto" runat="server" RenderMode="Inline">
<ContentTemplate>
<div class="DivTab">
<telerik:RadTabStrip ID="RadTabStripProjeto" runat="server" MultiPageID="RadMultiPageProjeto"
SelectedIndex="2" Align="Justify" ReorderTabsOnSelect="True" Width="600px" OnClientTabSelected="RadTabStripProjeto_TabSelected">
<Tabs>
<telerik:RadTab Text="Projetos Cadastrados" runat="server" Value="Cadastro">
</telerik:RadTab>
<telerik:RadTab Text="Função" Value="Função">
</telerik:RadTab>
<telerik:RadTab Text="Locais de Alocação" Value="Locais de Alocação" Selected="True">
</telerik:RadTab>
<telerik:RadTab Text="Equipe do Projeto" Value="Equipe do Projeto">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPageProjeto" runat="server" SelectedIndex="2" Height="100%"
CssClass="tabStrip">
<telerik:RadPageView ID="RadPageViewProjetosCadastrados" runat="server" Height="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewFuncao" runat="server" Height="100%" Width="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewLocaisAlocacao" runat="server" Height="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewEquipeProjeto" runat="server" Height="100%">
</telerik:RadPageView>
</telerik:RadMultiPage>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
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)
cSinonimos.CarregaTelerik(RadTabStripProjeto)
'RadTabStripProjeto.SelectedTab.PageView.ContentUrl = "../projeto/Default.aspx"
If ClassSGT.cSession.aplicaPermissoesAbas("Projetos", RadTabStripProjeto, Session("NOME").ToString()) Then
RadTabStripProjeto_TabClick(RadTabStripProjeto, New RadTabStripEventArgs(RadTabStripProjeto.SelectedTab))
Else
Response.Redirect("../AcessoNegado.aspx")
End If
Else
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
Try
lblError.Text = ""
Session("cadastre") = True
Response.Redirect("..\projeto\DefaultCadastro.aspx?vComando=Novo")
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
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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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
args.set_cancel(true);
//get the tab which is clicked
var tab = args.get_tab();
function CallBackFn(arg) {
if (arg) {
isTabClicked = "true";
tab.click();
}
}
//ask the user for confirmation
radconfirm("Os dados informados serão perdidos, deseja continuar?", CallBackFn);
}
}
}
function OnClientTabSelected() {
//reset the isTabClicked variable
isTabClicked = "false";
}
</script>
</telerik:RadCodeBlock>
</head>
<body onload="window.history.forward();" class="BODY">
<form runat="server" id="mainForm" method="post">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadWindowManager ID="RadWindowManager" runat="server" EnableShadow="true">
</telerik:RadWindowManager>
<asp:UpdatePanel ID="UpdatePanelProjeto" runat="server" RenderMode="Inline">
<ContentTemplate>
<div class="DivTab">
<telerik:RadTabStrip ID="RadTabStripProjeto" runat="server" MultiPageID="RadMultiPageProjeto"
SelectedIndex="2" Align="Justify" ReorderTabsOnSelect="True" Width="600px" OnClientTabSelected="RadTabStripProjeto_TabSelected">
<Tabs>
<telerik:RadTab Text="Projetos Cadastrados" runat="server" Value="Cadastro">
</telerik:RadTab>
<telerik:RadTab Text="Função" Value="Função">
</telerik:RadTab>
<telerik:RadTab Text="Locais de Alocação" Value="Locais de Alocação" Selected="True">
</telerik:RadTab>
<telerik:RadTab Text="Equipe do Projeto" Value="Equipe do Projeto">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPageProjeto" runat="server" SelectedIndex="2" Height="100%"
CssClass="tabStrip">
<telerik:RadPageView ID="RadPageViewProjetosCadastrados" runat="server" Height="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewFuncao" runat="server" Height="100%" Width="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewLocaisAlocacao" runat="server" Height="100%">
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageViewEquipeProjeto" runat="server" Height="100%">
</telerik:RadPageView>
</telerik:RadMultiPage>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
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)
cSinonimos.CarregaTelerik(RadTabStripProjeto)
'RadTabStripProjeto.SelectedTab.PageView.ContentUrl = "../projeto/Default.aspx"
If ClassSGT.cSession.aplicaPermissoesAbas("Projetos", RadTabStripProjeto, Session("NOME").ToString()) Then
RadTabStripProjeto_TabClick(RadTabStripProjeto, New RadTabStripEventArgs(RadTabStripProjeto.SelectedTab))
Else
Response.Redirect("../AcessoNegado.aspx")
End If
Else
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
Try
lblError.Text = ""
Session("cadastre") = True
Response.Redirect("..\projeto\DefaultCadastro.aspx?vComando=Novo")
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