c# - 右键单击时如何关闭/删除菜单项或选项卡?

标签 c# javascript jquery asp.net

我正在使用多 View 创建选项卡,我想做的是在右键单击其中一个菜单选项卡时关闭它。

这些是 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; 
}

这是示例输出:

enter image description here

TreeView 位于橙色部分(左)。而蓝色的是位于项目中的目标 url。根据我提供的代码,它只会指出一个名为“f1”的框架作为示例,尽管其中有 10 个。当我右键单击某个特定选项卡(例如“费用”选项卡)时,如何删除它?

我希望这在后面的代码中完成。对于 javascript/jquery 解决方案,请提供其代码隐藏实现或如何从代码隐藏调用/使用它。

请帮我解决这个问题。如需澄清,请发表评论。

谢谢!

最佳答案

我尝试了一种不同的方法。我没有使用右键单击,而是使用双击并确认来删除选项卡。

我还调整了用户定义的 JS 库以捕获双击并添加更多效果。

我还提到我已经有了我的 JavaScript 函数来处理这个我只是在寻找 JavaScript 或 JQuery 以外的替代品。但是令我惊讶的是我没有收到任何回复或评论。

感谢您阅读这篇文章。

关于c# - 右键单击时如何关闭/删除菜单项或选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16955676/

相关文章:

javascript - ASP :textbox Uncaught TypeError: Cannot read property 'value' of undefined

javascript - Webpack 和 Angular HTML 图片加载

javascript - 表格行的叠加

javascript - 如何在 jQuery 中解析日期字符串并检查它是否在过去

c# - SQL 存储过程未返回小数位

c# - 从 WebBrowser 控件向父应用程序发送消息

javascript - 有没有办法将多个(和不同的)参数从 Lightning Web 组件 (LWC) 中的 JS 传递到 Apex Controller 类?

javascript - Firefox 中的光标位置问题

c# - 在 C# 中正确实现 F# Unit

c# - "Processing of the LINQ expression ' GroupByShaperExpression“升级到 ef 核心后出错。5