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

相关推荐
小徐敲java1 分钟前
window使用phpStudy在nginx部署前端测试
运维·前端·nginx
Winslei3 分钟前
【hvigor专栏】OpenHarmony应用开发-hvigor插件之动态修改应用hap文件名
前端
扑棱蛾子11 分钟前
前端代码一键打包上传服务器?10分钟配好永久告别手动部署!
前端·node.js
q***T58319 分钟前
前端路由懒加载实现,React与Vue
前端·vue.js·react.js
灵犀坠23 分钟前
前端开发核心知识:HTML5特性与经典面试题详解
前端·html·html5
Hilaku24 分钟前
我为什么说全栈正在杀死前端?
前端·javascript·后端
8***B33 分钟前
前端性能优化插件,图片懒加载与压缩
前端
木易士心44 分钟前
Vue2 和 Vue3 中 watch 用法和原理详解
前端·vue.js
Harlen1 小时前
Cesium.js基本使用
前端
拿不拿铁191 小时前
Webpack 5.x 开发模式启动流程详解
前端