♣
看QUICKSTART 里的个人门户里的代码谁能说说这段代码什么意思啊?
using system;
using system.web;
using system.collections;
using system.web.ui;
using system.web.ui.htmlcontrols;
using system.web.ui.webcontrols;
public class defaultpage : portalmodulepage
{
public htmlanchor anchordelete;
public htmlanchor anchorcustomize;
public htmlanchor anchoroptions;
public htmlanchor anchoroptions2;
public htmlanchor anchoradd;
public label spanadd;
public label spandelete;
public htmlcontainercontrol pagepanellinks;
public placeholder leftuimodules;
public placeholder rightuimodules;
public panel login;
protected void page_load(object sender, eventargs e) {
int pageindex = 0;
if (request.querystring["_pageindex"] != null)
{
setpageindex(request.querystring["_pageindex"]);
pageindex = int32.parse(request.querystring["_pageindex"]);
}
else if (request.cookies["_pageindex"] != null) {
pageindex = int32.parse(request.cookies["_pageindex"].value);
}
if (pageindex != 0)
{
anchordelete.visible = true;
spandelete.visible = true;
}
else
{
anchordelete.visible = false;
spandelete.visible = false;
}
anchordelete.href = "/restricted/deletepage.aspx";
anchorcustomize.href = "/restricted/customize.aspx";
anchoroptions.href = "/restricted/options.aspx";
anchoroptions2.href = "/restricted/layout.aspx";
// dynamically construct page hyperlink list
buildpanelinklist(pagepanellinks, pageindex);
// dynamically construct module list for current page
buildmodulelist(leftuimodules, userstate["pagemodules_" + pageindex + "l"]);
buildmodulelist(rightuimodules, userstate["pagemodules_" + pageindex + "r"]);
databind();
}
private void buildmodulelist(control parent, string modules) {
if (modules == null)
return;
string [] modulelist = modules.split(new char[] {;});
if ((userstate["userid"]=="anonymous")&&(parent.id=="leftuimodules"))
login.visible=true;
for (int i=0;i<modulelist.length;i++) {
string modulesource = modulelist[i];
if ((modulesource != null)&&(modulesource != "")&&(modulesource != "system.dbnull")) {
control uimodule = page.loadcontrol(modulesource);
parent.controls.add(new literalcontrol("<tr><td>"));
parent.controls.add(uimodule);
parent.controls.add(new literalcontrol("</td></tr>"));
}
}
}
private void buildpanelinklist(htmlcontainercontrol container, int currentpageindex) {
string pagenames = userstate["pagenames"];
if (pagenames == null)
return;
string [] pagelist = pagenames.split(new char[] { ; });
if (pagelist.length > 2)
{
anchoradd.visible = false;
spanadd.visible = false;
}
else
{
anchoradd.visible = true;
spanadd.visible = true;
}
for (int i=0; i<pagelist.length; i++) {
if (pagelist[i] == null)
break;
if (i == currentpageindex) {
container.innerhtml += "<td align=center bgcolor=" + userstate["headcolor"] + " width=20%>";
container.innerhtml += " <table bgcolor=" + userstate["headcolor"] + " border=0 width=100% cellspacing=0 cellpadding=2>";
container.innerhtml += " <tr align=center>";
container.innerhtml += " <td></a><font face=arial, 宋体 color=white><b> "+pagelist[i]+"</b></font> </td>";
container.innerhtml += " </tr>";
container.innerhtml += " </table>";
container.innerhtml += "</td>";
container.innerhtml += "<td width=1%> </td>";
}
else {
container.innerhtml += "<td align=center bgcolor=" + userstate["subheadcolor"] + " width=20%>";
container.innerhtml += " <table bgcolor=" + userstate["subheadcolor"] + " border=0 width=100% cellspacing=0 cellpadding=2>";
container.innerhtml += " <tr align=center>";
container.innerhtml += " <td><font face=arial, 宋体 size=-1> <a href=default.aspx?_pageindex=" + i + ">"+pagelist[i]+"</a></font> </td>";
container.innerhtml += " </tr>";
container.innerhtml += " </table>";
container.innerhtml += "</td>";
container.innerhtml += "<td width=1%> </td>";
}
}
}
protected void signoff_click(object sender, eventargs e)
{
setpageindex("0");
system.web.security.formsauthentication.signout();
response.redirect("/default.aspx");
}
protected void addpage_click(object sender, eventargs e) {
if (string.compare(userstate["userid"],"anonymous") == 0)
{
response.redirect("/login.aspx");
}
else
{
string pagenames = userstate["pagenames"] + ";new page";
string[] pagelist = pagenames.split(new char[] { ; });
int numpages = pagelist.length - 1;
setpageindex(numpages.tostring());
userstate["pagenames"] = pagenames;
response.redirect("/restricted/customize.aspx");
}
}
private void setpageindex(string value)
{
httpcookie pageindex = new httpcookie("_pageindex", value);
pageindex.path = "/";
pageindex.expires = new datetime(2002, 10, 10);
response.appendcookie(pageindex);
}
}
· 网友精彩回答:
你要每行的註釋嗎
buildmodulelist函数用于动态加载用户控件的
不知道你哪不明白
.- 更多问题:
- · 水晶报表部署的问题。头大的都快爆了
- · 下载文件的问题.如何使下载的文件是有类型的.
- · C#如何windows服务列表
- · axis1.2RC2+ tomcat 5.0.12 + jdk 1.4.2_06 配置有问题,请指点
- · 这个查询怎么写呢?
- · asp.net可以监听键盘事件吗?
- · 在VS2003里,如何设定网页的大小?
- · FROM 子句语法错误?
- · 请教 一个统计和排序问题
- · 急急急急急急急急急急急急急急急急!非常急~高手帮忙 100分
- · 超急的问题!
- · 调用存储过程报告超时,但在查询分析器里面执行不到1秒钟。
- · 上海交通大学软件学院林老师幽默语录
- · 本人想建个asp.net的专业站点doaspx.com 但在CNBlogsDottext上遇到重重问题,还请兄弟们多多帮忙!
- · 老革命碰到新问题,不要灌水,要思考(起个名字,唉)
- · 【P2P专题讨论】之 NAT穿透
- · 服务器专栏
- · foxpro应用 | foxpro
- · ip指南
- · 验证码技术应用
- · mfc编程 | mfc
- · 脚本应用
- · 无线通信
- · ic测试
- · ic trade
- · load database
- · creat database
- · vc 位图
- · win iso
- · ati tool
- · 分布式服务器
- · 分布式监测系统
- · 使用汇编写进注册表启动的简单例子
- · 禁用注册表有什么用处
- · 注册表在哪
- · 电脑注册表损坏时出现的十种症状
- · 怎样修改注册表
- · 如何恢复注册表啊
- · 谁有注册表恢复工具?
- · 系统安全补丁
- · 最新firefox

