[英]How to close/remove menu item or tab when right click?
我正在使用多視圖創建選項卡,而我想要做的就是當我右鍵單擊它時關閉菜單選項卡之一。
這些是aspx和背后代碼的一部分:
ASPX頁面:
<asp:Menu
id="Menu1"
Orientation="Horizontal"
StaticMenuItemStyle-CssClass="tab"
StaticSelectedStyle-CssClass="selectedTab"
CssClass="tabs" width = "100%"
OnMenuItemClick="Menu1_MenuItemClick"
Runat="server" style=" text-align:center;">
</asp:Menu>
<div id="divcont" runat="server" class="tabContents" style="height:100%; width:100%;" visible="false">
<asp:MultiView
id="MultiView1"
ActiveViewIndex="0"
Runat="server">
<asp:View ID="v1" runat="server" >
<iframe id="f1" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v2" runat="server" >
<iframe id="f2" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v3" runat="server" >
<iframe id="f3" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v4" runat="server" >
<iframe id="f4" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v5" runat="server" >
<iframe id="f5" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v6" runat="server" >
<iframe id="f6" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v7" runat="server" >
<iframe id="f7" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v8" runat="server" >
<iframe id="f8" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v9" runat="server" >
<iframe id="f9" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
<asp:View ID="v10" runat="server" >
<iframe id="f10" runat="server" style="border: None; height: 100%; width: 100%;"></iframe>
</asp:View>
</asp:MultiView>
</div>
背后的代碼:
(這是NodeChanged事件的一部分)
...
...
...
int TabCount = Convert.ToInt32(lblTabCounter.Text.ToString());
int TabIndex = Convert.ToInt32(lblTabCounterIndex.Text.ToString());
if(TabCount <= 10)
{
divcont.Visible = true;
string tabName = getURLName(uRL);
MenuItem myItem = new MenuItem(tabName, TabIndex.ToString());
Menu1.Items.AddAt(TabIndex, myItem);
f1.Attributes.Add("src", lblURL.Text.ToString());
MultiView1.ActiveViewIndex = TabIndex;
TabCount++;
TabIndex++;
lblTabCounter.Text = TabCount.ToString();
lblTabCounterIndex.Text = TabIndex.ToString();
tvPermissions.ExpandAll();
int i = ctr;
}
(這是針對MenuItemClick事件的)
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
int index = Int32.Parse(e.Item.Value);
MultiView1.ActiveViewIndex = index;
}
這是示例輸出:
樹狀視圖位於橙色部分(左)。 藍色的是位於項目中的目標URL。 根據我提供的代碼,雖然其中有10個,但僅以一個名為“ f1”的幀為例。 當我右鍵單擊某個特定選項卡(例如“費用”選項卡)時,該如何刪除它?
我希望在后面的代碼中完成此操作。 對於javascript / jquery解決方案,請在實現后提供其代碼,或如何從后面的代碼中調用/使用它。
請幫我解決一下這個。 為了澄清,請發表評論。
謝謝!
我嘗試了另一種方法。 我使用右鍵單擊確認而不是右鍵單擊來刪除選項卡。
我還修改了用戶定義的JS庫,以捕獲雙擊並添加更多效果。
我還提到,我已經可以使用我的JavaScript函數了,我只是在尋找JavaScript或JQuery以外的替代方法。 但是,我沒有得到任何回應或評論,我感到很驚訝。
感謝您閱讀這篇文章。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.