简体   繁体   English

Ajax tabContainer属性设置

[英]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. 我正在使用具有5个tapPanel的Ajax选项卡容器创建管理面板,并且在每个tapPanel中,我都有一个标准工具面板。 And in that each Panel, I have GridView to show added data. 在每个面板中,我都有GridView来显示添加的数据。 And finally, I have one Add button outside of the Ajax tabContainer. 最后,我在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. 问题是,我只能添加第一个水龙头,即SPLASH,如果我添加第二个水龙头MAIN_CATEGORY,则该程序将数据添加到SPLASH中,或者向我显示错误消息“ FK约束”,但我的数据库设计很好。 I've found out the reason. 我找到了原因。 It actually depends on which TAP was clicked on when I run. 实际上,这取决于我在运行时单击了哪个TAP。 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. 例如,在右下角的像素中,单击了MAIN_CATEGORY,如果现在在浏览器中查看,则可以毫无问题地添加它,但是如果我移至其他水龙头并添加,它将显示问题。 So I assume it might be the setting. 因此,我认为这可能是设置。 Please refer to the pix. 请参考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 我当前的C#代码

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. 我对编程非常陌生,不知道如何使用Javascript函数。 Is Javascrip function thing is must to know to get this work??? 要完成这项工作,Javascrip函数是必须知道的事情吗??? If so, can it be written on source code or C# code page without creating JS files?? 如果是这样,可以在不创建JS文件的情况下将其写在源代码或C#代码页上吗?

I hope I explained clear Thanks! 希望我解释清楚谢谢!

Added One more pic 新增了一张图片 TabIndex值仍为“ 0”

try this 尝试这个

1) ajaxtoolkit:tabcontainer = add property AS activetabindex="0" 1)ajaxtoolkit:tabcontainer =添加属性AS activetabindex =“ 0”

2) ajaxToolkit:TabPanel tapSplash = add property AS TabIndex="0" 2)ajaxToolkit:TabPanel tapSplash =添加属性AS TabIndex =“ 0”

3) ajaxToolkit:TabPanel tapMainCat= add property AS TabIndex="1" 3)ajaxToolkit:TabPanel tapMainCat =添加属性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();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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