日期:2014-05-18  浏览次数:20391 次

如何制作基类页面,其他的页面从它继承过来?是制作.cs还是.aspx如何继承,能给出步骤么?
如何制作基类页面,其他的页面从它继承过来?是制作.cs还是.aspx如何继承,能给出步骤么? 

就是很多的页面的处理一样的,不一样的就是我们写的存储过程不同,还有页面的一些名字不同
应如何写一基类页面,别的页面继承?

能给个例子嘛?发邮件也可以..如有,另300分再开一贴相送..谢谢

------解决方案--------------------
1\是写一个.cs文件做为基类,不过这个基类要继承自system.web.ui.page
public class a:system.web.ui.page
{
这个基类的某方法完成你的工作,如重写page类某方法
}

2\你的.aspx文件要继承自a
------解决方案--------------------

------解决方案--------------------
Discuz!NT PageBase基类
C# code

using System;
using System.IO;
using System.Web;
using System.Text.RegularExpressions;
using Discuz.Forum;
using Discuz.Common;
using Discuz.Config;
using Discuz.Entity;

namespace Discuz.Web.UI.Pages
{
    /// <summary>
    /// Discuz!NT页面基类
    /// </summary>
    public class BasePage : System.Web.UI.Page
    {
            public string forumpath = BaseConfigs.GetForumPath;
 
       
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public BasePage()
        {

            config = GeneralConfigs.GetConfig();

            LoadUrlConfig();
            
            userid = Utils.StrToInt(ForumUtils.GetCookie("userid"), -1);

            //清空当前页面查询统计
            Discuz.Data.DbHelper.QueryCount = 0;
 
            // 如果启用游客页面缓存
            if (userid == -1)
            {
                if (config.Guestcachepagetimeout > 0)
                {
                    switch (pagename)
                    {
                        case "website.aspx":
                            isguestcachepage = GetCachePage(pagename);
                            break;
                        case "forumindex.aspx":
                            isguestcachepage = GetCachePage(pagename);
                            break;
                        case "spaceindex.aspx":
                            isguestcachepage = GetCachePage(pagename);
                            break;
                        case "albumindex.aspx":
                            isguestcachepage = GetCachePage(pagename);
                            break;
                        case "showtopic.aspx":
                            int pageid = DNTRequest.GetQueryInt("page", 1);
                            int topicid = DNTRequest.GetQueryInt("topicid", 0);
                            if (pageid == 1 && DNTRequest.GetParamCount() == 2 && topicid > 0 && ForumUtils.ResponseTopicCacheFile(topicid, config.Guestcachepagetimeout))
                            {
                                TopicStats.Track(topicid, 1);
                                return;
                            }
                            break;
                        default:
                            //
                            break;
                    }
                }
            }

            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);


            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }

          

            //当为forumlist.aspx或focuslist_aspx,可能出现在线并发问题,这时系统会延时2秒
            if((pagename != "forumlist.aspx") && (pagename != "focuslist.aspx"))
            {
                oluserinfo = OnlineUsers.Update