看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);
}
}