cs的很多不同之处,造成了很多用户的使用上的不习惯。但是我们又不能对cs做太多的修改,那样就不是cs了,何况升级也不便。
其实cs已经为我们提供了一个论坛下拉菜单,不过是用在最新帖子列表页面的,采用的是自动回发的方法,用在其它版面就不合适了。所以我简单的继承了这个控件,用一个新的类ForumJumpDropDownList.cs,就生成了一个采用js跳转的新控件:论坛快速跳转下拉菜单,代码如下:
//
------------------------------
// www.cnfdc.com.cn
// 王勇 2006-8-21
// wangyong.yichang@gmail.com
// -----------------------------
using System;
using System.Collections;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls
... {
/**//// <summary>
/// 论坛跳转下拉菜单,继承自ForumDropDownList
/// </summary>
public class ForumJumpDropDownList : ForumDropDownList
...{
public ForumJumpDropDownList()
...{
string script = string.Empty;
script = @"if(this.value!='f--1'){if(this.value.indexOf('g-')>=0){window.location.href='/forums/default.aspx?GroupID='+this.value.replace('g-','')}else if(this.value.indexOf('f-')>=0){window.location.href='/forums/'+this.value.replace('f-','')+'/ShowForum.aspx'}}";
this.Attributes.Add("onchange", script);
}
}
}
// www.cnfdc.com.cn
// 王勇 2006-8-21
// wangyong.yichang@gmail.com
// -----------------------------
using System;
using System.Collections;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls
... {
/**//// <summary>
/// 论坛跳转下拉菜单,继承自ForumDropDownList
/// </summary>
public class ForumJumpDropDownList : ForumDropDownList
...{
public ForumJumpDropDownList()
...{
string script = string.Empty;
script = @"if(this.value!='f--1'){if(this.value.indexOf('g-')>=0){window.location.href='/forums/default.aspx?GroupID='+this.value.replace('g-','')}else if(this.value.indexOf('f-')>=0){window.location.href='/forums/'+this.value.replace('f-','')+'/ShowForum.aspx'}}";
this.Attributes.Add("onchange", script);
}
}
}
重新编译这个dll,然后再在View-Threads.ascx的相应位置加入这个控件,就可以啦
跳转论坛到:
<
CSD:ForumJumpDropDownList
ID
="ForumJumpDropDownList1"
runat
="server"
/>
就这么简单!试试看吧!