我正在使用Ajax标签容器创建管理面板,该容器有5个tapPanel,每个tapPanel,我有一个标准工具面板。在每个Panel中,我都有GridView来显示添加的数据。最后,我在Ajax tabContainer之外有一个Add按钮。问题是,我只能添加SPLASH的第一个水龙头,如果我添加第二个水龙头MAIN_CATEGORY,程序会将数据添加到SPLASH或显示错误信息" FK约束"但我的DB设计很好。我发现了原因。它实际上取决于我运行时点击了哪个TAP。例如,在右下方的pix中,单击MAIN_CATEGORY,如果我现在在浏览器中查看,我可以毫无问题地添加它,但如果我移动到其他点击并添加它会显示问题。所以我认为它可能是设置。请参考pix。
我目前的源代码
<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 --%>
我当前的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
}
//我试过
protected void btnAddCat_Click(object sender, EventArgs e)
{
int CurrentTab = TabConAddInfo.ActiveTabIndex;
switch (CurrentTab)
{
case 0:
addSplash();
break;
case 1:
addMainCat();
break;
}
//也尝试了
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();
}
我对编程非常陌生,我不知道如何使用Javascript函数。 Javascrip功能是必须要知道才能得到这个工作吗?如果是这样,它可以写在源代码或C#代码页上而不创建JS文件吗?
我希望我解释清楚谢谢!
又添了一张照片
答案 0 :(得分:0)
试试这个
1)ajaxtoolkit:tabcontainer = add property AS activetabindex =“0”
2)ajaxToolkit:TabPanel tapSplash =添加属性AS TabIndex =“0”
3)ajaxToolkit:TabPanel tapMainCat =添加属性AS TabIndex =“1”
然后
试试这个
protected void btnAddCat_Click(object sender, EventArgs e)
{
if (TabConAddInfo.ActiveTab.TabIndex == 0)
{
addSplash();
}
else if (TabConAddInfo.ActiveTab.TabIndex == 1)
{
addMainCat();
}
}