• Asp.net自定义控件 带参数


    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="News.ascx.cs" Inherits="News" %>
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
        <li>
        ·<a href="<%# strurl(Eval("isoutlink").ToString(),Eval("pagepath").ToString())%>" class="def" rel="external"><%# GetStrLength(Eval("title").ToString(),14)%></a>
        </li>
        </ItemTemplate> 
    </asp:Repeater>
    <asp:Label ID="lb_error" runat="server" Visible="False"></asp:Label>

     private string _dispnum = ""; //定义显示条数
        public string dispnum
        {
            get
            {
                return _dispnum;
            }
            set
            {
                _dispnum = value;
            }
        }

        private string _classid = ""; //定义新闻类别ID
        public string classid
        {
            get
            {
                return _classid;
            }
            set
            {
                _classid = value;
            }
        }

        private int _strlen = 1; //定义显示长度
        public int strlen
        {
            get
            {
                return _strlen;
            }
            set
            {
                _strlen = value;
            }
        }
        protected string GetStrLength(string str, int len)
        {
            if (str.Length < this.strlen)
                return str;
            str = str.Substring(0, this.strlen);
            return str;
        }

    调用:

    <%@ Register Src="UserControl/News.ascx" TagName="News" TagPrefix="uc8" %>

    <uc8:News ID="News12" runat="server" dispnum="6" strlen="25" classid="zbgg" />

  • 相关阅读:
    3288 积木大赛
    3284 疯狂的黄大神
    1531 山峰
    1018 单词接龙
    1432 总数统计
    1507 酒厂选址
    1063 合并果子
    几个sort不能过的题目
    poj 2245 Lotto
    求两圆相交面积模板
  • 原文地址:https://www.cnblogs.com/jcomet/p/2002896.html
Copyright © 2020-2023  润新知