• 如何生成动态选项卡


    1:前台HTML:  <div id="Divtag" runat="server">

    前台JS:

    //传入标签ID,并触发按钮事件

     function Tagclick(tag_value) {
                document.getElementById('<%=hdfTag.ClientID %>').value = tag_value;
                document.getElementById('<%=btnTagClick.ClientID %>').click();

    }

    <asp:HiddenField ID="hdfTag" runat="server" />
        <div style="visibility: hidden">
            <asp:Button ID="btnTag" runat="server" OnClick="btnTagClick" />//按钮事件
        </div>

    2:首先获取含有动态标签名与动态标签的ID的集合;如datable:

     foreach (DataRow dr in tag.Tables[0].Rows)
                {

                    divHtml = String.Format("<a onclick=\"Tagclick('{0}')\">{1}</a>", dr["TagID"], dr["TagName"]);
                    TableCell td1 = new TableCell();
                    TableCell td2 = new TableCell();
                    TableCell td3 = new TableCell();

                    if ((dr["TagID"].ToString() == PID))
                    {

                       //当为选中状态时标签的颜色发生改变
                        td1.Attributes.Add("style", "background-image:url(/Image/lab1.gif); background-repeat:no-repeat; 4px; height:25px;");
                        td2.Attributes.Add("style", "background-image:url(/Image/lab2.gif); background-repeat:repeat-x;");
                        td3.Attributes.Add("style", "background-image:url(/Image/lab3.gif); background-repeat:no-repeat; 4px; height:25px;");
                    }
                    else
                    {

                        //未选中时
                        td1.Attributes.Add("style", "background-image:url(/Image/lab11.gif); background-repeat:no-repeat; 4px; height:25px;");
                        td2.Attributes.Add("style", "background-image:url(/Image/lab12.gif); background-repeat:repeat-x;");
                        td3.Attributes.Add("style", "background-image:url(/Image/lab13.gif); background-repeat:no-repeat; 4px; height:25px;");
                    }

                    td2.Controls.Add(new LiteralControl(divHtml));
                    this.Divtag.Controls.Add(td1);
                    this.Divtag.Controls.Add(td2);
                    this.Divtag.Controls.Add(td3);
                }

  • 相关阅读:
    原生searchView 自定义样式
    面试问题总结
    Android Studio开发环境搭建
    JAVA基本程序设计结构
    JAVA大数使用
    sql
    普通树的递归遍历
    6_43_递归交换二叉树中所有节点的左右子树
    6_42_二叉树递归求叶子节点个数
    6_44_二叉树中值为x的节点为根的子树的深度
  • 原文地址:https://www.cnblogs.com/Jack_G/p/2301409.html
Copyright © 2020-2023  润新知