home *** CD-ROM | disk | FTP | other *** search
-
- <%@ Register TagPrefix="Acme" TagName="SourceCtrl" Src="/quickstart/util/SrcCtrl.aspx"%>
- <%@ Import Namespace="System.Text" %>
- <%@ Import Namespace="System.IO" %>
-
- <link rel="stylesheet" href="/quickstart/util/style.css">
-
- <script language="C#" runat="server">
-
- public bool showtitle = true;
- public bool listonly = false;
- public String width = "100%";
- public String path;
-
- public void Page_Load (Object sender, EventArgs e)
- {
- if (path == null)
- path = Request.QueryString["path"];
-
- if (path == null)
- {
- ErrorMessage.InnerHtml = "Please specify a path variable in the querystring.";
- return;
- }
-
- String file = Request.QueryString["file"];
-
- if (file != null) {
- String dir = File.GetDirectoryNameFromPath(path);
- MySourceCtrl.filename = Server.MapPath(dir + "\\" + file);
- }
-
- // BUGBUG: HtmlTable doesn't store ViewState, so must populate on every request
-
- FileStream fs = new FileStream(Server.MapPath(path),FileMode.Open,FileAccess.Read);
- StreamReader sr = new StreamReader(fs);
- String line = sr.ReadLine();
-
- while (line != null)
- {
- HtmlTableRow row = new HtmlTableRow();
-
- // BUGBUG: HtmlTableCell String Constructor is Failing...
- HtmlTableCell cell = new HtmlTableCell();
-
- String[] list = line.Split(new char[] { ':' });
-
- if (!(list.Length > 1)) break;
-
- String sourcegroup = list[0];
-
- cell.InnerHtml = "<b>" + sourcegroup + ": </b>";
- cell.Style.Add("padding-right","10");
- row.Cells.Add(cell);
-
- String[] sourcelist = list[1].Split(new char[] { ',' });
-
- if ((file==null)&&(sourcelist.Length>0))
- {
- String dir = File.GetDirectoryNameFromPath(path);
- MySourceCtrl.filename = Server.MapPath(dir + "\\" + sourcelist[0]);
- file = sourcelist[0];
- }
-
- StringBuilder sb = new StringBuilder();
- for (int i=0; i<sourcelist.Length; i++)
- {
- String sourcefile = sourcelist[i];
-
- if (listonly)
- sb.Append("<a target='_blank' href='/quickstart/util/srcctrlwin.aspx?path=" + path + "&file=" + sourcefile + "'>");
- else
- sb.Append("<a href='/quickstart/util/srcview.aspx?path=" + path + "&file=" + sourcefile + "'>");
-
- sb.Append(sourcefile);
- sb.Append("</a>  ");
- }
-
- cell = new HtmlTableCell();
- cell.InnerHtml = sb.ToString();
- row.Cells.Add(cell);
- SourceTable.Rows.Add(row);
-
- line = sr.ReadLine();
- }
-
- fs.Close();
-
- if (showtitle != false)
- Title.InnerHtml = file; //Path.GetName(path);
- else
- Title.InnerHtml = "";
- }
-
- public void LinkButton_Click (Object sender, EventArgs e)
- {
- // do nothing
- }
-
- </script>
-
- <form runat="server">
-
- <div class="SampleHeader" style="width:<%=width%>">
- <div class="SampleTitle">
- <span id="Title" runat="server">ASP+ Source Code Viewer</span>
- </div>
- <table id="SourceTable" MaintainState="true" style="font: 8pt Verdana" runat="server"/>
- </div>
-
- <Acme:SourceCtrl id="MySourceCtrl" runat="server" />
- <span style="color:red" id="ErrorMessage" runat="server"/>
-
- </form>
-