none
TabContainer RRS feed

  • Pergunta

  • Bom dia Pessoal!

    Seguinte, eu tenho um TabContainer es estou tentando fazer validação nas Tabpanel, mas eu não consigo pegar a tab ativa.

    Mesmo que preencha todos os campos de uma guia ele cobra que preencha os da outra guia.

    Não consigo salvar.

    Segue o código:

    <%@ Page Title="" Language="C#" MasterPageFile="~/FrontPage.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="IASD.ASCS.WebForm.moviment.stock.Default" %>
    
    <%@ MasterType VirtualPath="~/FrontPage.Master" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <link href="../../Content/template.css" rel="stylesheet" />
        <link href="../../Content/validationEngine.jquery.css" rel="stylesheet" />
    
        <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../../Scripts/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
        <script src="../../Scripts/jquery.validationEngine-pt_BR.js" type="text/javascript" charset="utf-8"></script>
    
        <script type="text/javascript">
            //jQuery(document).ready(function () {
            //    jQuery("#form1").validationEngine();
            //});
    
            function validate() {
    
                if (sender.get_activeTabIndex() == 0) {
    
                if (document.getElementById("<%=ddlSchoolStock.ClientID%>").value.trim() == "") {
                    alert("Preencha o Campo obrigatório");
                    document.getElementById("<%=ddlSchoolStock.ClientID%>").focus();
                    return false;
                }
    
                if (document.getElementById("<%=ddlProductTypeStock.ClientID%>").value.trim() == "") {
                    alert("Preencha o Campo obrigatório");
                    document.getElementById("<%=ddlProductTypeStock.ClientID%>").focus();
                    return false;
                }
    
                if (document.getElementById("<%=ddlProductStock.ClientID%>").value.trim() == "") {
                    alert("Preencha o Campo obrigatório");
                    document.getElementById("<%=ddlProductStock.ClientID%>").focus();
                    return false;
                }
    
                if (document.getElementById("<%=txtQuantidade.ClientID%>").value.trim() == "") {
                    alert("Preencha o Campo obrigatório");
                    document.getElementById("<%=txtQuantidade.ClientID%>").focus();
                    return false;
                }
    
            }
    
            }
    
    
        </script>
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <div class="buttons">
            <asp:ImageButton ID="btnSearch" runat="server" ImageUrl="~/Images/search.png" OnClick="btnSearch_Click" />
            <asp:ImageButton ID="btnNew" runat="server" ImageUrl="~/Images/add.png" ToolTip="Novo Estoque" OnClick="btnNew_Click" />
            <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/exclude_G.png" OnClick="btnDelete_Click" />
            <asp:ImageButton ID="btnSave" runat="server" ImageUrl="~/Images/save_G.png" ToolTip="Salvar Estoque" ValidationGroup="vlProductType" OnClick="btnSave_Click" OnClientClick="return validate()" />
            <asp:HyperLink ID="hlPrint" runat="server" ImageUrl="~/Images/print.png" ToolTip="Imprimir" Target="_blank" Enabled="False">HyperLink</asp:HyperLink>
        </div>
        <cc1:TabContainer ID="TabGroup" runat="server" TabIndex="0" Width="100%" CssClass="ajax__myTab" ActiveTabIndex="0">
            <cc1:TabPanel runat="server" HeaderText="Menus" ID="tbStock">
                <HeaderTemplate>Estoque</HeaderTemplate>
                <ContentTemplate>
                    <div id="Div2">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <div class="table_search_">
                                    <fieldset>
                                        <table style="width: 100%;">
                                            <tr>
                                                <td>
                                                    <asp:Label ID="Label4" runat="server" Text="Escola"></asp:Label></td>
                                                <td>
                                                    <asp:Label ID="Label5" runat="server" Text="Tipo de Produto"></asp:Label></td>
                                                <td>
                                                    <asp:Label ID="Label6" runat="server" Text="Produto"></asp:Label></td>
                                                <td>
                                                    <asp:Label ID="Label7" runat="server" Text="Quantidade"></asp:Label></td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <asp:DropDownList ID="ddlSchoolStock" runat="server" CssClass="validate[required] dropdown" AutoPostBack="True" OnSelectedIndexChanged="ddlSchoolStock_SelectedIndexChanged"></asp:DropDownList></td>
                                                <td>
                                                    <asp:DropDownList ID="ddlProductTypeStock" runat="server" CssClass="validate[required] dropdown" AutoPostBack="True" OnSelectedIndexChanged="ddlProductTypeStock_SelectedIndexChanged"></asp:DropDownList></td>
    
                                                <td>
                                                    <asp:DropDownList ID="ddlProductStock" runat="server" CssClass="validate[required] dropdown" AutoPostBack="True" OnSelectedIndexChanged="ddlProductStock_SelectedIndexChanged"></asp:DropDownList>&nbsp;</td>
                                                <td>
                                                    <asp:TextBox ID="txtQuantidade" CssClass="validate[required] textbox_search" runat="server" Width="102px" OnTextChanged="txtQuantidade_TextChanged"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                <asp:HiddenField ID="hfQuantidade" runat="server" />
                                                </td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <caption>
                                                <br />
                                                <asp:Label ID="lblMessage" runat="server"></asp:Label>
                                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                            </caption>
                                        </table>
                                    </fieldset>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                    <div class="GridMain">
                        <asp:GridView ID="gvStock" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" CssClass="GridViewUser" ForeColor="#333333" GridLines="None" PageSize="20" Width="100%" OnRowUpdating="gvStock_RowUpdating" OnPageIndexChanging="gvStock_PageIndexChanging">
                            <AlternatingRowStyle BackColor="White" CssClass="GridAlternativeUser" />
                            <Columns>
                                <asp:BoundField HeaderText="Cód Escola" DataField="SchoolID" />
                                <asp:BoundField HeaderText="ID Produto" DataField="ProductID" />
                                <asp:BoundField HeaderText="Tipo do Produto" DataField="NameProductType" />
                                <asp:BoundField HeaderText="Nome Produto" DataField="NameProduct" />
                                <asp:BoundField HeaderText="Quantidade" DataField="Quantity" />
                                <asp:ButtonField ButtonType="Image" CommandName="Update" ImageUrl="~/images/edit.png" />
                            </Columns>
                            <EditRowStyle BackColor="#2461BF" />
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#507CD1" CssClass="GridHeaderUser" Font-Bold="True" ForeColor="White" />
                            <PagerSettings PageButtonCount="5" />
                            <PagerStyle BackColor="#62AFC1" CssClass="GridPagerUser" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#EFF3FB" CssClass="GridRowUser" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#F5F7FB" />
                            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                            <SortedDescendingCellStyle BackColor="#E9EBEF" />
                            <SortedDescendingHeaderStyle BackColor="#4870BE" />
                        </asp:GridView>
                    </div>
                    <asp:ValidationSummary ID="vsGroup" runat="server" ValidationGroup="vsGroup" ForeColor="Red" />
                </ContentTemplate>
            </cc1:TabPanel>
            <cc1:TabPanel runat="server" HeaderText="Grupo" ID="tbSearch">
                <HeaderTemplate>Pesquisa</HeaderTemplate>
                <ContentTemplate>
                    <div id="Div1">
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                            <ContentTemplate>
                                <div class="table_search_">
                                    <fieldset>
                                        <table style="width: 100%;">
                                            <tr>
                                                <td>
                                                    <asp:Label ID="Label1" runat="server" Text="Escola"></asp:Label></td>
                                                <td>
                                                    <asp:Label ID="Label2" runat="server" Text="Tipo de Produto"></asp:Label></td>
                                                <td>
                                                    <asp:Label ID="Label3" runat="server" Text="Nome do Produto"></asp:Label></td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <asp:DropDownList ID="ddlSchool" runat="server" CssClass="validate[required] dropdown" OnSelectedIndexChanged="ddlSchool_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList></td>
                                                <td>
                                                    <asp:DropDownList ID="ddlProductType" runat="server" CssClass="dropdown" OnSelectedIndexChanged="ddlProductType_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList></td>
                                                <td>
                                                    <asp:TextBox ID="txtNameProduct" CssClass="textbox_search" runat="server"></asp:TextBox></td>
                                                <td>&nbsp;&nbsp;</td>
                                                <td>&nbsp;</td>
                                            </tr>
                                        </table>
                                    </fieldset>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                    <asp:GridView ID="gvPesquisa" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" CssClass="GridViewUser" ForeColor="#333333" GridLines="None" OnPageIndexChanging="gvPesquisa_PageIndexChanging" PageSize="20" Width="100%" OnRowUpdating="gvPesquisa_RowUpdating">
                        <AlternatingRowStyle BackColor="White" CssClass="GridAlternativeUser" />
                        <Columns>
                            <asp:BoundField HeaderText="Cód Escola" DataField="SchoolID" />
                            <asp:BoundField HeaderText="ID Produto" DataField="ProductID" />
                            <asp:BoundField HeaderText="Tipo do Produto" DataField="NameProductType" />
                            <asp:BoundField HeaderText="Nome Produto" DataField="NameProduct" />
                            <asp:BoundField HeaderText="Quantidade" DataField="Quantity" />
                            <asp:ButtonField ButtonType="Image" CommandName="Update" ImageUrl="~/images/edit.png" />
                        </Columns>
                        <EditRowStyle BackColor="#2461BF" />
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#507CD1" CssClass="GridHeaderUser" Font-Bold="True" ForeColor="White" />
                        <PagerSettings PageButtonCount="5" />
    
                        <PagerStyle BackColor="#62AFC1" CssClass="GridPagerUser" ForeColor="White" HorizontalAlign="Center" />
    
                        <RowStyle BackColor="#EFF3FB" CssClass="GridRowUser" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F5F7FB" />
                        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                        <SortedDescendingCellStyle BackColor="#E9EBEF" />
                        <SortedDescendingHeaderStyle BackColor="#4870BE" />
                    </asp:GridView>
                </ContentTemplate>
            </cc1:TabPanel>
        </cc1:TabContainer>
    </asp:Content>
    

    segunda-feira, 3 de fevereiro de 2014 11:20

Todas as Respostas

  • Jaque, 

    Tenta fazer isso no seu codebehind, no evento click do seu botão. 

    http://social.msdn.microsoft.com/Forums/pt-BR/a33343cd-76e3-4262-a75c-7512af036762/alguem-sabe-pq-qdo-um-alert-mostrado-o-tabcontainer-e-outros-comp-html-bagunam?forum=504

    Abraço.

    segunda-feira, 3 de fevereiro de 2014 11:36