ADO.Net前端页面调用后台方法使用

1、前台页面定义GetSource方法,传入列表显示字段;

cs 复制代码
<asp:Repeater ID="rptList" runat="server">
    <ItemTemplate>
        <tr class="lsi-t">
            <td>
                <%# Container.ItemIndex+1 %>
            </td>
            <td>
                  <%# GetSource(Eval("source").ToString())%>
             </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

2、后台页面定义Public公共类型的方法GetSource;

cs 复制代码
public string GetSource(string source)
{
    string sourcename = "";
    if(source=="1")//1 = 网页;
    {
        sourcename = "<img title=\"" + Resources.lang.WebPage+ "\" src=\"../img/wangye.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "2")//2 = APP;
    {
        sourcename = "<img title=\"" + Resources.lang.APP + "\" src=\"../img/APP.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "3")//3 = 微信小程序;
    {
        sourcename = "<img title=\"" + Resources.lang.WeChatMini + "\" src=\"../img/xiaochengxu.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "4")//4 = 公众号;
    {
        sourcename = "<img title=\"" + Resources.lang.OfficialAccounts + "\" src=\"../img/gongzhonghao.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "5")//5 = 对外接口;
    {
        sourcename = "<img title=\"" + Resources.lang.ExternalInterface + "\" src=\"../img/duiwaijiekou.png\" style=\"width:20px;height:22px;margin-top:4px;\" />";
    }
    return sourcename;
}

3、后台可以根据字段值判断列中需要显示的图标、数值;

相关推荐
dsyyyyy110117 分钟前
HTML总结
前端·html
前端那点事1 小时前
深度解析:Vue中computed的实现原理(易懂不晦涩)
前端·vue.js
Mike_jia1 小时前
PortNote:可视化端口管理工具,让端口冲突成为历史
前端
前端那点事1 小时前
Vue中深克隆的3种实现方案(附详细注释+测试)
前端·vue.js
存在X1 小时前
claude code自定义模型
前端·claude
Highcharts.js1 小时前
赋能金融 SaaS|如何利用 Highcharts 与 Morningstar 数据构建顶级分析仪表盘
前端·金融·echarts·saas·bi·highcharts
啷咯哩咯啷1 小时前
纯本地运行的私人文档知识库
前端·人工智能·后端
❆VE❆1 小时前
基于 contenteditable 实现变量插入富文本编辑器
前端·javascript·vue.js
Aliex_git1 小时前
Nuxt 学习笔记(一)
前端·笔记·学习
烤麻辣烫1 小时前
json与fastjson
前端·javascript·学习·json