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

相关推荐
前端Hardy11 分钟前
别再忽略 Promise 拒绝了!你的 Node.js 服务正在“静默自杀”
前端·javascript·面试
前端Hardy13 分钟前
别再被setTimeout闭包坑了!90% 的人都写错过这个经典循环
前端·javascript·vue.js
小林coding19 分钟前
专为程序员打造的简历模版来啦!覆盖前端、后端、测开、大模型等专业简历
前端·后端
前端Hardy19 分钟前
你的 Vue 组件正在偷偷吃掉内存!5 个常见的内存泄漏陷阱与修复方案
前端·javascript·面试
RaidenLiu30 分钟前
Flutter Platform Channel 底层架构解析 —— 从 BinaryMessenger 到跨平台消息通信机制
前端·flutter·前端框架
bluceli32 分钟前
CSS容器查询:响应式设计的新范式
前端·css
Tapir36 分钟前
被 Karpathy 下场推荐的 NanoClaw 是什么来头
前端·后端·github
前端人类学36 分钟前
深入解析JavaScript中的null与undefined:区别、用法及判断技巧
前端·javascript
ssshooter2 小时前
Tauri 项目实践:客户端与 Web 端的授权登录实现方案
前端·后端·rust
兆子龙2 小时前
【React】19 深度解析:掌握新一代 React 特性
前端·架构