我现在只能发表100的贴子~!结贴前加分!
以aspnetpager为例,我想做一个自己的控件,不知如何下手~!
分页控件的原理是什么?

解决方案 »

  1.   

    演练:创建 Web 自定义控件
      

  2.   

    1、打开vs
    2、在解决方案资源管理器中右键单击—添加—新建项
    3、选择Web用户控件
    4、单击添加按钮。
    5、打开新建的那个后缀名ascx的文件。
    6、编辑(随便画几个表格,弄张图片)。
    7、保存。
    8、这时,一个用户自定义控件就算做好了,可以把刚才新建的文件(控件)随意拖到想用的地方。
      

  3.   

      写自定义控件 首先在 先建项目 和 先选择 web ,再选asp.net 服务哭控件
      

  4.   

    写自定义控件 首先在 新建项目时 先选择C# 中的 web ,再选asp.net 服务哭控件 就可写自定义控件了
      

  5.   

    研究控件源码QuickPager 
      

  6.   

    aspnetpager源码找了好久,都睛DEMO源码,dll的源码没找到啊~!
    还有,有变动,我后天才能上车,所以贴子要大后天才能结~!
      

  7.   

    1.新建一个派生自WebControl的类,
    2.重写Render(HtmlTextWriter writer)实现功能,
    3.编译成类库
    4.在应用的工程的工具箱内添加选择项,拖进页面就行了,系统会自动注册控件的
     
      

  8.   

    maek 了 顺便帮楼主顶上去
      

  9.   

    说原理难  毕竟微软公布的源码不多
    只不过是继承一些微软些好的软件 然后加功能  改写下等等...
    像AspNetPager:using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.IO;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.Design.WebControls;
    using System.Web.UI.WebControls;
    using System.Web;
    using System.Resources;
    using System.Globalization;
    using System.Security.Permissions;
    using System.Text.RegularExpressions;namespace FrameWork.WebControls
    {
        #region AspNetPager Server Control    /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Class[@name="AspNetPager"]/*'/>
        [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
        [DefaultProperty("PageSize")]
        [DefaultEvent("PageChanged")]
        [ParseChildren(false)]
        [PersistChildren(false)]
        [ANPDescription("desc_AspNetPager")]
        [Designer(typeof(PagerDesigner))]
        [ToolboxData("<{0}:AspNetPager runat=server></{0}:AspNetPager>")]
        public class AspNetPager : Panel, INamingContainer, IPostBackEventHandler, IPostBackDataHandler
        {
            #region Private fields        private string cssClassName;
            private string inputPageIndex;
            private string currentUrl = null;
            private NameValueCollection urlParams = null;
            private AspNetPager cloneFrom = null;
            private static readonly object EventPageChanging = new object();
            private static readonly object EventPageChanged = new object();
            //AspNetPager Version information
            const string ver = "6.0.0";        #endregion        #region Properties        #region Navigation Buttons        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="ShowNavigationToolTip"]/*'/>
            [Browsable(true), ANPCategory("cat_Navigation"), DefaultValue(false), ANPDescription("desc_ShowNavigationToolTip"), Themeable(false)]
            public bool ShowNavigationToolTip
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.ShowNavigationToolTip;
                    object obj = ViewState["ShowNvToolTip"];
                    return (obj == null) ? false : (bool)obj;
                }
                set
                {
                    ViewState["ShowNvToolTip"] = value;
                }
            }        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="NavigationToolTipTextFormatString"]/*'/>
            [Browsable(true), Themeable(false), ANPCategory("cat_Navigation"), ANPDefaultValue("def_NavigationToolTipTextFormatString"), ANPDescription("desc_NavigationToolTipTextFormatString")]
            public string NavigationToolTipTextFormatString
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.NavigationToolTipTextFormatString;
                    object obj = ViewState["NvToolTipFormatString"];
                    if (obj == null)
                    {
                        if (ShowNavigationToolTip)
                            return SR.GetString("def_NavigationToolTipTextFormatString");
                        return null;
                    }
                    return (string)obj;
                }
                set
                {
                    string tip = value;
                    if (tip.Trim().Length < 1 && tip.IndexOf("{0}") < 0)
                        tip = "{0}";
                    ViewState["NvToolTipFormatString"] = tip;
                }
            }        /// <include file='AspnetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="NumericButtonTextFormatString"]/*'/>
            [Browsable(true), Themeable(false), DefaultValue(""), ANPCategory("cat_Navigation"), ANPDescription("desc_NBTFormatString")]
            public string NumericButtonTextFormatString
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.NumericButtonTextFormatString;
                    object obj = ViewState["NumericButtonTextFormatString"];
                    return (obj == null) ? String.Empty : (string)obj;
                }
                set
                {
                    ViewState["NumericButtonTextFormatString"] = value;
                }
            }        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="PagingButtonType"]/*'/>
            [Browsable(true), Themeable(false), DefaultValue(PagingButtonType.Text), ANPCategory("cat_Navigation"), ANPDescription("desc_PagingButtonType")]
            public PagingButtonType PagingButtonType
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.PagingButtonType;
                    object obj = ViewState["PagingButtonType"];
                    return (obj == null) ? PagingButtonType.Text : (PagingButtonType)obj;
                }
                set
                {
                    ViewState["PagingButtonType"] = value;
                }
            }        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="NumericButtonType"]/*'/>
            [Browsable(true), Themeable(false), DefaultValue(PagingButtonType.Text), ANPCategory("cat_Navigation"), ANPDescription("desc_NumericButtonType")]
            public PagingButtonType NumericButtonType
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.NumericButtonType;
                    object obj = ViewState["NumericButtonType"];
                    return (obj == null) ? PagingButtonType : (PagingButtonType)obj;
                }
                set
                {
                    ViewState["NumericButtonType"] = value;
                }
            }        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="NavigationButtonType"]/*'/>
            [Browsable(true), Themeable(false), ANPCategory("cat_Navigation"), DefaultValue(PagingButtonType.Text), ANPDescription("desc_NavigationButtonType")]
            public PagingButtonType NavigationButtonType
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.NavigationButtonType;
                    object obj = ViewState["NavigationButtonType"];
                    return (obj == null) ? PagingButtonType : (PagingButtonType)obj;
                }
                set
                {
                    ViewState["NavigationButtonType"] = value;
                }
            }        /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="MoreButtonType"]/*'/>
            [Browsable(true), Themeable(false), ANPCategory("cat_Navigation"), DefaultValue(PagingButtonType.Text), ANPDescription("desc_MoreButtonType")]
            public PagingButtonType MoreButtonType
            {
                get
                {
                    if (null != cloneFrom)
                        return cloneFrom.MoreButtonType;
                    object obj = ViewState["MoreButtonType"];
                    return (obj == null) ? PagingButtonType : (PagingButtonType)obj;
                }
                set
                {
                    ViewState["MoreButtonType"] = value;
                }
            }...