• <%#Eval if判断用法


    1、绑定Repeater 基础用法

       <%#Eval("RoleID")%>

    2、简单判断用法

    <td>
    <%# Convert.ToBoolean(Eval("UserIsSupperPower")) ? "<span id='spIsSupperman' style='color:green'>" + superman + "</span>" : no%>
    </td>

    3、较复杂用法

       <a  href="EditUser.aspx?action=edit&id=<%# Eval("UserID")%>&t=' + new Date().getTime()';" ><span class='am-icon-pencil-square-o'></span><%=edit %></a> &nbsp;

    4、复杂用法,用一个后台方法,封装,前台输出

       <%# IsDisplayItem(Eval("RoleDescription"),Eval("RoleID")) %>

    后台代码

    /// <summary>
            /// 根据角色描述 判断是否为移动端角色项,如是则隐藏编辑项
            /// </summary>
            /// <param name="roleDesc"></param>
            /// <param name="roleId"></param>
            /// <returns></returns>
            public string IsDisplayItem(object roleDesc,object roleId) 
            {
                string strResult = "";
                if (!roleDesc.ToString().Contains("移动"))
                {
                    strResult = "<a href='EditRole.aspx?Action=Edit&RoleId=" + roleId + "&t=' + new Date().getTime());" + "><span class='am-icon-pencil-square-o'></span>";
                    strResult += edit + "</a> &nbsp;&nbsp";
                    strResult += "<a href='?action=delete&RoleId=" + roleId + " style='color:#dd514c;' onclick='return confirm($('#hidAlertDelete.ClientID').val());'>";
                    strResult += " <span class='am-icon-trash-o'></span>" + delete + "</a>";
                }
                 return strResult;
            }

    5、拓展下<% if%>用法

    <%if(true)%>
    <%{%>
    <asp:TextBox id="Textbox2" style="Z-INDEX: 101; LEFT: 240px; POSITION: absolute; TOP: 88px" runat="server"></asp:TextBox>
    <asp:Button id="Button2" style="Z-INDEX: 102; LEFT: 256px; POSITION: absolute; TOP: 128px" runat="server" Text="Button"></asp:Button>
    <SELECT style="Z-INDEX: 103; LEFT: 272px; WIDTH: 176px; POSITION: absolute; TOP: 184px">
    <OPTION selected></OPTION>
    </SELECT>
    <%}%>
    <%else%>
    <%{%>
    <asp:TextBox id="Textbox3" style="Z-INDEX: 101; LEFT: 240px; POSITION: absolute; TOP: 88px" runat="server"></asp:TextBox>
    <SELECT style="Z-INDEX: 103; LEFT: 272px; WIDTH: 176px; POSITION: absolute; TOP: 184px">
    <OPTION selected></OPTION>
    </SELECT>
    <%}%>

  • 相关阅读:
    手写vite
    单点登录的实现原理
    vue中和react中key的用法
    手写MVVM
    rtvue-lowcode:一款基于uniapp框架和uview组件库的开源低代码开发平台
    博图TIA中ModbusRTU_CRC校验程序的实现
    博图TIA中ModbusRTU Over TCP/IP通讯的实现
    webpack之file-loader和url-loader的区别
    Webpack中Loader和Plugin的区别?编写Loader,Plugin的思路?
    spark-sql 与hive 常用函数
  • 原文地址:https://www.cnblogs.com/markli/p/4971772.html
Copyright © 2020-2023  润新知