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、后台可以根据字段值判断列中需要显示的图标、数值;

相关推荐
fangzhanpeng16831 分钟前
(前端)2.js变量作用域样例
开发语言·前端·javascript
赵广陆35 分钟前
企业实战:web服务集成
前端·pycharm·fastapi
demo007x1 小时前
Hermes-Agent 技术架构
前端·后端·agent
码艺-Alimjan3 小时前
Vue项目源码备份最佳实践:无视node_modules,打包体积仅2MB
前端·javascript·vue.js
隔窗听雨眠3 小时前
esbuild构建工具简介:重新定义前端构建速度的极速打包器
前端
蔓越莓3 小时前
Webpack 常用 Loader +手写Loader
前端·面试
潍坊老登4 小时前
写了一个某音自动刷视频,通过大模型分析视频主题的Android应用
前端
蔓越莓4 小时前
性能优化:webpack打包层面优化
前端·面试