简体   繁体   中英

Ajax tabContainer properties setting

I'm creating Admin Panel using Ajax tab container which has 5 tapPanels and in that each tapPanel, I have one Panel from standard tool. And in that each Panel, I have GridView to show added data. And finally, I have one Add button outside of the Ajax tabContainer. The problem is, I only can ADD the 1st tap which is SPLASH, if I add 2nd tap MAIN_CATEGORY, either the program adds the data into SPLASH or shows me an error msg "FK constrain" but my DB design is fine. I've found out the reason. It actually depends on which TAP was clicked on when I run. For example, in the bottom right pix, MAIN_CATEGORY is clicked, if I view in browser now, I can add it without any problem but it'll show the problem if I move to other tap and add. So I assume it might be the setting. Please refer to the pix.

我目前的设定VS 2012

My current Source Code

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
                <ajaxToolkit:TabContainer ID="TabConAddInfo" ActiveTabIndex="2" runat="server" AutoPostBack="True" OnClientActiveTabChanged="tabChanged" OnActiveTabChanged="btnAddCat_Click" >
                    <ajaxToolkit:TabPanel ID="tapSplash" HeaderText="Splash" ActiveTabIndex="0" runat="server"><HeaderTemplate>Splash</HeaderTemplate>

                        <ContentTemplate>

                        <asp:Panel ID="Panel1" runat="server" >
                             <%-- My textboxes and labels --%>

                            <div style= "Overflow:scroll ;max-height: 200px; width: auto" >

                                <asp:GridView ID="GridViewAddSplash" runat="server" AutoGenerateColumns="False" Font-Names="Arial" Font-Size="Small" HorizontalAlign="Center">
                                    <Columns>
                                        <asp:BoundField DataField="VersionNumber" HeaderText="Version #" >
                                        <ItemStyle Width="10%" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="LoginID" HeaderText="Admin ID" >                                       
                            </asp:Panel>
                        </ContentTemplate>
</ajaxToolkit:TabPanel>

<ajaxToolkit:TabPanel ID="tapMainCat" runat="server" HeaderText="Main Category" ActiveTabIndex="1" ><HeaderTemplate>Main Category</HeaderTemplate>

                    <ContentTemplate>                           
                            <asp:Panel ID="Panel2" runat="server" >                              
                                <%-- My textboxes and labels --%>

My current C# code

protected void btnAddCat_Click(object sender, EventArgs e)
        {
            AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabConAddInfo;
            int index = container.ActiveTabIndex;

            if (index == 0)
            {
                addSplash();
            }
            else if (index == 1)
            {
                addMainCat();
            }

  protected void TabConAddInfo_ActiveTabChanged(object sender, EventArgs e)
        {
           //I have this but don't know how it works and I prefer ADD to action not the TAB  
        }

// I have tried

protected void btnAddCat_Click(object sender, EventArgs e)
    {
    int CurrentTab = TabConAddInfo.ActiveTabIndex;
                switch (CurrentTab)
                {
                    case 0:
                        addSplash();
                        break;
                    case 1:
                        addMainCat();
                        break;
    }

//Also tried

protected void btnAddCat_Click(object sender, EventArgs e)
        {
            AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabConAddInfo;
            AjaxControlToolkit.TabPanel tcTabPanel = new AjaxControlToolkit.TabPanel();


            if (tcTabPanel.HeaderText == "SPLASH")
            {
                addSplash();
            }
            else if (tcTabPanel.HeaderText == "MAIN_CATEGORY")
            {
                addMainCat();
            }

I'm very new to programming and I have no idea how to use Javascript Functions. Is Javascrip function thing is must to know to get this work??? If so, can it be written on source code or C# code page without creating JS files??

I hope I explained clear Thanks!

Added One more pic TabIndex值仍为“ 0”

try this

1) ajaxtoolkit:tabcontainer = add property AS activetabindex="0"

2) ajaxToolkit:TabPanel tapSplash = add property AS TabIndex="0"

3) ajaxToolkit:TabPanel tapMainCat= add property AS TabIndex="1"

Then

try this

protected void btnAddCat_Click(object sender, EventArgs e)
{
    if (TabConAddInfo.ActiveTab.TabIndex == 0)
    {
        addSplash();
    }
    else if (TabConAddInfo.ActiveTab.TabIndex == 1)
    {
        addMainCat();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM