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

相关推荐
T___T15 分钟前
写着写着,就踩进了 JavaScript 的小坑
前端·javascript·面试
月亮慢慢圆20 分钟前
首字母模糊匹配
前端
一个有理想的摸鱼选手21 分钟前
CesiumLite-在三维地图中绘制3D图形变得游刃有余
前端·gis·cesium
一千柯橘21 分钟前
Three.js 坐标系完全入门:从“你在哪”到“你爸在哪”都讲清楚了
前端
独角仙梦境22 分钟前
同事:架构太复杂了,源码文件找半天。 我:源码溯源了解一下?
前端·vue.js
八哥程序员22 分钟前
从border-image 到 mask + filer 实现圆角渐变边框
前端·css
ChangYo23 分钟前
解决网页前端中文字体包过大的几种方案
前端
车前端23 分钟前
现代 Nginx 优化实践:架构、配置与性能调优
前端·nginx
槁***耿27 分钟前
前端路由守卫
前端
百***354829 分钟前
前端视频处理开发
前端·音视频