YetAnotherForum 学习总结

--------------------------------------
1 关于ascx如何从所在的页面中取页面传递的值?
   在ascx.cs中Page_Load()中,可直接调用Request[<Key>]来取
--------------------------------------
2 在ascx中如何改变所在页面aspx中控件的值?
      System.Web.UI.WebControls.TextBox ctl;
      //System.Web.UI.HtmlControls.***
      //有两个控件集,Web和 Html
      ctl = (System.Web.UI.WebControls.TextBox)Page.FindControl("TextBox1");
      //取到后,进行相应的操作
--------------------------------------
3 转字符型的函数:
    1 Convert   2 int.Parse
--------------------------------------
4 在ascx中使用HttpContext用:
    HttpContext.Current.Response,
    HttpContext.Current.Cache
    Response.Redirect   改变页面的目录
    HttpContext.Current.Request.QueryString
--------------------------------------
5 获取浏览期的类型可用:
if ( HttpContext.Current.Request.UserAgent.IndexOf( "Windows NT 5.2" ) >= 0 )
     platform = "Win2003";
HttpContext.Current.Session.SessionID,
     PageBoardID,
     User.Name,
     HttpContext.Current.Request.UserHostAddress,
//ip     HttpContext.Current.Request.FilePath,
     HttpContext.Current.Request.Browser.Browser,
//浏览器     HttpContext.Current.Request.Browser.Platform,     
//系统
--------------------------------------
6  关于 Hashtable
//create
System.Collections.Hashtable t = Mession.ForumRead;
   if ( t == null )
   {
    t = new System.Collections.Hashtable();
   }
   t [forumID] = date;
//取
System.Collections.Hashtable t = Mession.ForumRead;
   if ( t == null || !t.ContainsKey( forumID ) )
    return ( DateTime ) Mession.LastVisit;
   else
    return ( DateTime ) t [forumID];
--------------------------------------
7 关于字符川格式的组成:
ctl.Text= string.Format( "{0};{1};{2}", "wo", "12", "iop" );
//结果是:wo;12;iop
--------------------------------------
8.yaf论坛的页面引导方式:
******
   Pages page;   //引导的集合
   string m_baseDir = Data.ForumRoot;

   try
   {
    page = ( Pages ) System.Enum.Parse( typeof( Pages ), Request.QueryString ["g"], true );
       //g的值:forum,topics,posts...等. 从首页上的工具栏调用
   }
   catch ( Exception )
   {
    page = Pages.forum;
   }

   if ( !ValidPage( page ) )
   {
    Forum.Redirect( Pages.topics, "f={0}", LockedForum );
   }
   //根据集合中的字符串,生成需要加载的页面
   string src = string.Format( "{0}pages/{1}.ascx", m_baseDir, page );
   if ( src.IndexOf( "/moderate_" ) >= 0 )
    src = src.Replace( "/moderate_", "/moderate/" );
   if ( src.IndexOf( "/admin_" ) >= 0 )
    src = src.Replace( "/admin_", "/admin/" );
   if ( src.IndexOf( "/help_" ) >= 0 )
    src = src.Replace( "/help_", "/help/" );

   try
   {
    pages.ForumPage ctl = ( pages.ForumPage ) LoadControl( src );
    ctl.ForumControl = this;

    this.Controls.Add( ctl );
    //
   }
   catch ( System.IO.FileNotFoundException )
   {
    throw new ApplicationException( "Failed to load " + src + "." );
   }
****************
public System.Web.UI.Control LoadControl(string virtualPath)
    System.Web.UI.TemplateControl 的成员

摘要:
根据指定的虚拟路径从文件加载 System.Web.UI.Control 对象。

参数:
virtualPath: 控件文件的虚拟路径。

返回值:
返回指定的 System.Web.UI.Control。
******ForumControl**定义如下
  private Forum m_forumControl = null;
  public yaf.Forum ForumControl
  {
   get
   {
    if ( m_forumControl != null )
     return m_forumControl;

    System.Web.UI.Control ctl = Parent;
    while ( ctl.GetType() != typeof( yaf.Forum ) )
     ctl = ctl.Parent;

    m_forumControl = ( yaf.Forum ) ctl;
    return m_forumControl;
   }
   set
   {
    m_forumControl = value;
   }
  }
********
public class Forum : System.Web.UI.UserControl
******************
 public enum Pages
 {
  forum,
  topics,
  posts,
  profile,
  activeusers,
  moderate,
  postmessage,
  mod_forumuser,
  attachments,
  pmessage,
  movetopic,
  emailtopic,
  printtopic,
  members,
  cp_inbox,
  cp_profile,
  cp_editprofile,
  cp_editavatar,
  cp_signature,
  cp_subscriptions,
  cp_message,
  login,
  approve,
  info,
  rules,
  register,
  search,
  active,
  logout,
  moderate_index,
  moderate_forum,
  error,
  avatar,
  admin_admin,
  admin_hostsettings,
  admin_boards,
  admin_boardsettings,
  admin_forums,
  admin_bannedip,
  admin_smilies,
  admin_accessmasks,
  admin_groups,
  admin_users,
  admin_ranks,
  admin_mail,
  admin_prune,
  admin_pm,
  admin_attachments,
  admin_eventlog,
  admin_nntpservers,
  admin_nntpforums,
  admin_nntpretrieve,
  admin_version,
  admin_bannedip_edit,
  admin_editaccessmask,
  admin_editboard,
  admin_editcategory,
  admin_editforum,
  admin_editgroup,
  admin_editnntpforum,
  admin_editnntpserver,
  admin_editrank,
  admin_edituser,
  // Added BAI 07.01.2004  
  admin_reguser,
  // Added BAI 07.01.2004
  admin_smilies_edit,
  admin_smilies_import,
  // Added Rico83
  admin_replacewords,
  admin_replacewords_edit,
  im_yim,
  im_aim,
  im_icq,
  im_email,
  rsstopic,
  help_index,
  help_recover,
  lastposts
 }
--------------------------------------
9.所有的ascx 都从类ForumPage中继承。调用基类的函数用  :base
  public partial class login : ForumPage
 {

  public login()
   : base( "LOGIN" )
  {
  }
--------------------------------------
10.比如调用注册时,中间有参数:ReturnUrl.为返回的地址.
   这种设计思路: 
Default.aspx?g=  只有一个参数
Default.aspx页面中控件"<yaf:forum runat="server" id="forum" />"接受到参数后,根据参数的类别改边自身对应的ascx文件.
控件"<yaf:forum runat="server" id="forum" />"中引发调用其他的页面的时间.用Pages.info来获取 Default.aspx的内容,再加上相应的参数.   控件中的刷新,引起页面(Default.aspx)中的刷新.
   
--------------------------------------
11.c#中把n行字符放在一个变量中,使用 @.如下:
string javascript = string.Format( @"
<script language=""javascript"">
 var called = false;
        }");

--------------------------------------
12.登陆成功后,调用:
    string idName = string.Format( "{0};{1};{2}", userID, PageBoardID, UserName.Text );

    if ( Request.QueryString ["ReturnUrl"] != null )
    {
     FormsAuthentication.RedirectFromLoginPage( idName, AutoLogin.Checked );
    }
    else
    {
     FormsAuthentication.SetAuthCookie( idName, AutoLogin.Checked );
     Forum.Redirect( Pages.forum );
    }
*********************
public sealed class FormsAuthentication
    System.Web.Security 的成员

摘要:
为 Web 应用程序管理 Forms 身份验证服务。无法继承此类。
*******
public static void SetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath)
    System.Web.Security.FormsAuthentication 的成员

摘要:
为提供的用户名创建一个身份验证票证,并使用提供的 Cookie 路径或 URL 将其添加到响应的 Cookie 集合。

参数:
userName: 已验证的用户的名称。
createPersistentCookie: 若要创建持久 Cookie(跨浏览器会话保存的 Cookie),则为 true;否则为 false。
strCookiePath: Forms 身份验证票证的 Cookie 路径。
********
public static void RedirectFromLoginPage(string userName, bool createPersistentCookie)
    System.Web.Security.FormsAuthentication 的成员

摘要:
将经过身份验证的用户重定向回最初请求的 URL 或默认 URL。

参数:
userName: 经过身份验证的用户名。
createPersistentCookie: 若要创建持久 Cookie(跨浏览器会话保存的 Cookie),则为 true;否则为 false。
**************
public string RawUrl { get; }
    System.Net.HttpListenerRequest 的成员

摘要:
获取客户端请求的 URL 信息(不包括主机和端口)。

返回值:
System.String 包含此请求的原始 URL。
--------------------------------------
13 .如果要集成的话,调用
string idName = string.Format( "{0};{1};{2}", userID, PageBoardID, UserName.Text );  1
FormsAuthentication.SetAuthCookie( idName, false );
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
5JBB.COM中文版版本号:version1.0-2007-7-10 开源协议:GPL 5JBB.COM中文版对原版的修改: 1.用户界面完美汉化,包括修复了原版中错误的汉化和js脚本和UBB编辑器中的未汉化的英文(后台管理部分还是英文的); 2.修复原版中当发表需要审核的话题或从首页以外的页面进入login页面时URLRewrite定位错误找不到资源的Bug; 3.修复原版中FlatEarth皮肤下JavaScript脚本报错的Bug; 4.新增允许为浏览器中显示的URL增加自定义前缀,例如,原版中所有URL中页面前缀只能为yaf_, 修改版可以在web.config中设置appSetting['PagePrefix']并替换URLRewrite正则表达式中的所有yaf_为自定义前缀, 如修改版中默认的5jbb_; 5.新增允许自定义所有的RSS中的简介和版权信息,原版是固定死是原版程序的简介和版权信息, 只需要设置web.config中的appSetting['RSSDesc']和appSetting['RSSCopyright']; 6.新增基于Cookie的自动记忆上次用户离开网站时的论坛分类展开、折起信息; 7.新增允许设置默认折起的论坛分类,只需要设置web.config中的appSetting['DefaultCollapsedForumCategories']的value 为以逗号分隔的论坛分类ID值(逗号和ID值间不能带空格); 8.为注册页面、登录页面、发表/修改话题页面和回复话题页面增加了随机验证码; DB下为数据库文件,附加即可,在web.config中配置一下数据库连接 默认管理员账号密码均为admin 也可以采用以下步骤进行安装: 1.解压缩所有代码到一个目录 2.复制Default.config为web.config,并修改其中的指向已建立的数据库,为upload目录设置写权限; 3.如果不是将本程序安装于网站根目录,则需要在web.config中的yafnet配置块中添加一个root,如/forum/yaf/; 4.打开./install/default.aspx,例如:http://YourSite/forum/install/; 5.安装过程需要Admin权限。 由5jbb汉化

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值