看QUICKSTART 里的个人门户里的代码谁能说说这段代码什么意思啊?

aspys 2005-07-14 12:38:13
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);
}
}
...全文
133 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
aspys 2005-07-15
  • 打赏
  • 举报
回复
谢谢上面的回复,唉我差不多都不明白,谁可以帮我剖析这个示例站,什么条件我都可以答应(力所能及)。
Thristian 2005-07-14
  • 打赏
  • 举报
回复
不知道你哪不明白
fengfangfang 2005-07-14
  • 打赏
  • 举报
回复
BuildModuleList函数用于动态加载用户控件的
fengfangfang 2005-07-14
  • 打赏
  • 举报
回复
哪里不明白,详细说说
sykpboy 2005-07-14
  • 打赏
  • 举报
回复
你要每行的註釋嗎

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧