ASP不渲染生成页面

时间:2015-02-19 13:54:56

标签: c# asp.net rendering

有一个没有任何错误的ASP页面,但是在页面加载后页面呈现为空白页面。但是,如果我复制生成的代码,并将其放入另一个ASP页面并加载该页面,它就会很好地渲染。这几乎就像我需要在代码末尾的东西说现在你已经完成运行代码显示生成的html。

<%@ Page AutoEventWireup="true" Language="c#" CodeBehind="DefaultCS.aspx.cs" Inherits="DefaultCS.WebForm1"%>



string[] projects = null;
//string winlogon = Request.ServerVariables["LOGON_USER"];
//string User = winlogon.Substring(8, winlogon.Length - 8);
projects = renderProjectIDs("HCQ763");
string Level1 = "";
string Level2 = "";
string Level3 = "";
int linedone = 0;



Response.Write("<!DOCTYPE html>" + System.Environment.NewLine);

Response.Write("<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">" + System.Environment.NewLine);

Response.Write("<head runat=\"server\"> </head>" + System.Environment.NewLine);
Response.Write("    <body>" + System.Environment.NewLine);

    Response.Write("<form id=\"form1\" runat=\"server\">" + System.Environment.NewLine);
    Response.Write("<asp:TreeView runat=\"server\" Width=\"105px\">" + System.Environment.NewLine);
    Response.Write("<Nodes>" + System.Environment.NewLine);
    Response.Write("<asp:TreeNode Text=\"Capital Projects\" Value=\"Capital Projects\">" + System.Environment.NewLine);

string[] tempArray = new string[2];
for(int y=0; y<projects.Length; y++)
  {
    tempArray = projects[y].Split('|');
    linedone = 0;
    if ((Level3 != "") && (Level3 != tempArray[5])) //If a level 3 has been built and we come back up we need to make an end TreeNode
    {
        Response.Write("</asp:TreeNode>" + System.Environment.NewLine); //End the Last Level 3 Node
    }
    if ((Level2 != "") && (Level2 != tempArray[3]))  //If a level 2 has been built and we come back up we need to make an end TreeNode
    {
        Response.Write("</asp:TreeNode>" + System.Environment.NewLine); //End the last Level 2 Node
        Level3 = "";
    }
    if ((Level1 != "") && (Level1 != tempArray[1])) //If a level 1 has been built and we come back up we need to make an end TreeNode
    {
        Response.Write("</asp:TreeNode>" + System.Environment.NewLine); //End the last Level 1 Node
        Level2 = "";
    }





    if ((Level1 != tempArray[1]) && (tempArray[1] != tempArray[3])) //Level 1 Node has changes
    {
       Response.Write("<asp:TreeNode Text=\"" + tempArray[0] + "\" Value=\"" + tempArray[0] + "\">" + System.Environment.NewLine); //Write the new Level 1 Node
       Level1 = tempArray[1];
    }
    else if (tempArray[1] == tempArray[3]) // Level 2 and Level 3 ID in the database are the same this means that the Record is a CIP
    {
        //Write out the CIP
        linedone = 1;
        Response.Write("<asp:TreeNode Value=\"" + tempArray[8] + "\" Text=\"" + tempArray[1] + "\" NavigateUrl=\"CapitalText.aspx?CID=" + tempArray[8] + "\" Target=\"frame_main\"></asp:TreeNode>" + System.Environment.NewLine);
    }  
    if ((Level2 != tempArray[3]) && (tempArray[3] != tempArray[5])) //Level 2 Node Changed
    {
        Response.Write("<asp:TreeNode Text=\"" + tempArray[2] + "\" Value=\"" + tempArray[2] + "\">" + System.Environment.NewLine);   //Write the new Level 2 Node
        Level2 = tempArray[3];
    } else if ((tempArray[3] == tempArray[5]) && (linedone == 0)) // Level 2 and Level 3 ID in the database are the same this means that the Record is a CIP
        {
            //Write out the CIP
            linedone = 1;
            Response.Write("<asp:TreeNode Value=\"" + tempArray[8] + "\" Text=\"" + tempArray[2] + "\" NavigateUrl=\"CapitalText.aspx?CID=" + tempArray[8] + "\" Target=\"frame_main\"></asp:TreeNode>" + System.Environment.NewLine);
        }
    if ((Level3 != tempArray[5]) && (tempArray[5] != tempArray[7]))
    {
        Response.Write("<asp:TreeNode Text=\"" + tempArray[4] + "\" Value=\"" + tempArray[4] + "\">" + System.Environment.NewLine); //Write the new Level 3 Node
        Level3 = tempArray[5];
    }
    else if ((tempArray[5] == tempArray[7]) && (linedone == 0)) // IF Level 3 and Level 4 IDs in the database are the same this means that the Record is a CIP
    {
           //Write out the CIP
        linedone = 1;
        Response.Write("<asp:TreeNode Value=\"" + tempArray[8] + "\" Text=\"" + tempArray[4] + "\" NavigateUrl=\"CapitalText.aspx?CID=" + tempArray[8] + "\" Target=\"frame_main\"></asp:TreeNode>" + System.Environment.NewLine);
    }
    if ((tempArray[5] != tempArray[7]) && (linedone == 0))
    {
        Response.Write("<asp:TreeNode Value=\"" + tempArray[8] + "\" Text=\"" + tempArray[6] + "\" NavigateUrl=\"CapitalText.aspx?CID=" + tempArray[8] + "\" Target=\"frame_main\"></asp:TreeNode>" + System.Environment.NewLine);
    }




 }


          Response.Write("</asp:TreeNode>" + System.Environment.NewLine);
        Response.Write("</asp:TreeNode>" + System.Environment.NewLine);
    Response.Write("</Nodes>" + System.Environment.NewLine);
Response.Write("</asp:TreeView>" + System.Environment.NewLine);
  Response.Write("</form>" + System.Environment.NewLine);
Response.Write("</body>" + System.Environment.NewLine);

Response.Write("</html>" + System.Environment.NewLine);
%>

这是生成的代码

<!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server"> </head>
        <body>
    <form id="form1" runat="server">
    <asp:TreeView runat="server" Width="105px">
    <Nodes>
    <asp:TreeNode Text="Capital Projects" Value="Capital Projects">
    <asp:TreeNode Text="Hennepin County Total" Value="Hennepin County Total">
    <asp:TreeNode Text="Public Works" Value="Public Works">
    <asp:TreeNode Text="Transportation Roads & Bridges" Value="Transportation Roads & Bridges">
    <asp:TreeNode Value="2986401" Text="2986401  CSAH 3 - Construct Lake St ramps at I-35W - Participation" NavigateUrl="CapitalText.aspx?CID=2986401" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="2070500" Text="2070500  CSAH 5 - Reconst. Franklin Ave Bridge over Mississippi River" NavigateUrl="CapitalText.aspx?CID=2070500" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="2142600" Text="2142600 CSAH 20 - Reconstruct Blake Road from TH 7 to Excelsior Blvd" NavigateUrl="CapitalText.aspx?CID=2142600" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="2141200" Text="2141200  CSAH 28 - Participate in MnDOT I-494 Ramp reconstruction" NavigateUrl="CapitalText.aspx?CID=2141200" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="2141100" Text="2141100 CSAH 30 - Reconst 93rd Ave N fr Xylon Ave to East of Winnetka" NavigateUrl="CapitalText.aspx?CID=2141100" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="2974800" Text="2974800  CSAH 34 - Reconst Normandale fr W 94th St to Mt Normandale Dr" NavigateUrl="CapitalText.aspx?CID=2974800" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Housing Community Works and Transit" Value="Housing Community Works and Transit">
    <asp:TreeNode Value="1002195" Text="1002195   Economic Development Infrastructure Fund" NavigateUrl="CapitalText.aspx?CID=1002195" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001560" Text="1001560   Penn Avenue Community Works" NavigateUrl="CapitalText.aspx?CID=1001560" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031720" Text="0031720   Community Works Corridor Planning" NavigateUrl="CapitalText.aspx?CID=0031720" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001648" Text="1001648   Lowry Avenue NE Community Works" NavigateUrl="CapitalText.aspx?CID=1001648" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031721" Text="0031721   Fort Snelling Upper Post" NavigateUrl="CapitalText.aspx?CID=0031721" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002318" Text="1002318   Bottineau LRT Community Works" NavigateUrl="CapitalText.aspx?CID=1002318" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031591" Text="0031591   Community Works Northwest Corridor" NavigateUrl="CapitalText.aspx?CID=0031591" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031805" Text="0031805   Southwest LRT Community Works" NavigateUrl="CapitalText.aspx?CID=0031805" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031742" Text="0031742   Minnehaha-Hiawatha Community Works" NavigateUrl="CapitalText.aspx?CID=0031742" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Environmental  Services" Value="Environmental  Services">
    <asp:TreeNode Value="0031704" Text="0031704   HERC Facility Preservation & Improvement" NavigateUrl="CapitalText.aspx?CID=0031704" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002150" Text="1002150   HERC Pres & Improvements 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002150" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031814" Text="0031814   HERC District Energy" NavigateUrl="CapitalText.aspx?CID=0031814" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000319" Text="1000319   Transfer Station Facility Pres 2012-2015" NavigateUrl="CapitalText.aspx?CID=1000319" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002151" Text="1002151   Transfer Station Pres 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002151" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Property Services" Value="Property Services">
    <asp:TreeNode Value="0031822" Text="0031822   Environmental Health & Safety 2011-2015" NavigateUrl="CapitalText.aspx?CID=0031822" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002153" Text="1002153   Environmental Health & Safety 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002153" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000874" Text="1000874   Government Center Rehabilitation" NavigateUrl="CapitalText.aspx?CID=1000874" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031823" Text="0031823   Facility Preservation 2011-2015" NavigateUrl="CapitalText.aspx?CID=0031823" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002154" Text="1002154    Facility Preservation 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002154" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031730" Text="0031730   Multi-building Critical Power" NavigateUrl="CapitalText.aspx?CID=0031730" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031825" Text="0031825   Southdale Regional Ctr Preservation & Remodeling" NavigateUrl="CapitalText.aspx?CID=0031825" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002308" Text="1002308   Ridgedale Regional Center Preservation" NavigateUrl="CapitalText.aspx?CID=1002308" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031824" Text="0031824   Building Auto. Sys Upgrades 2011-2015" NavigateUrl="CapitalText.aspx?CID=0031824" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002155" Text="1002155    Building Auto. Sys Upgrades 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002155" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001928" Text="1001928   HCGC Admin Space Efficiency & Security Improvements" NavigateUrl="CapitalText.aspx?CID=1001928" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002242" Text="1002242   Countywide Security Equipment Replacement" NavigateUrl="CapitalText.aspx?CID=1002242" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031827" Text="0031827   Public and Programmatic Furniture Replacement" NavigateUrl="CapitalText.aspx?CID=0031827" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031672" Text="0031672   Accessibility Modifications" NavigateUrl="CapitalText.aspx?CID=0031672" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002156" Text="1002156   Accessibility Modifications 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002156" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002158" Text="1002158   Carpet Replacement Program 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002158" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000328" Text="1000328   701 Building Facility Preservation" NavigateUrl="CapitalText.aspx?CID=1000328" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002159" Text="1002159   701 Building Facility Preservation 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002159" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000329" Text="1000329   701 Building Office Space Modifications" NavigateUrl="CapitalText.aspx?CID=1000329" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002157" Text="1002157    General Office Space & Furniture Mods 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002157" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Public Safety and Judiciary" Value="Public Safety and Judiciary">
    <asp:TreeNode Text="Emergency Management" Value="Emergency Management">
    <asp:TreeNode Value="1001563" Text="1001563   Emergency Mgmt Vehicle Storage Bldg" NavigateUrl="CapitalText.aspx?CID=1001563" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="District Court" Value="District Court">
    <asp:TreeNode Value="0031746" Text="0031746   Government Center C-11 Modifications" NavigateUrl="CapitalText.aspx?CID=0031746" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001655" Text="1001655   Traffic Violations Bureau Improvements" NavigateUrl="CapitalText.aspx?CID=1001655" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000932" Text="1000932   Jury Assembly Relocation" NavigateUrl="CapitalText.aspx?CID=1000932" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001168" Text="1001168   Conciliation Court Relocation" NavigateUrl="CapitalText.aspx?CID=1001168" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031841" Text="0031841   Hearings & Fines Office Relocation" NavigateUrl="CapitalText.aspx?CID=0031841" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031838" Text="0031838   Self Help Center Relocation" NavigateUrl="CapitalText.aspx?CID=0031838" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031840" Text="0031840   Brookdale Third Courtroom Completion" NavigateUrl="CapitalText.aspx?CID=0031840" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000931" Text="1000931   Courtroom Communications Syst Refurb 2013-2015" NavigateUrl="CapitalText.aspx?CID=1000931" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002161" Text="1002161   Courtroom Communications Syst Refurb 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002161" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001562" Text="1001562   FJC Courtroom Remodel" NavigateUrl="CapitalText.aspx?CID=1001562" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Community Corrections" Value="Community Corrections">
    <asp:TreeNode Value="0031789" Text="0031789   Community Corrections Security Modifications" NavigateUrl="CapitalText.aspx?CID=0031789" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000320" Text="1000320   Community Corrections Facility Pres 2012-2015" NavigateUrl="CapitalText.aspx?CID=1000320" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002162" Text="1002162   Community Corrections Facility Pres 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002162" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000321" Text="1000321   Community Corrections Flooring Replacement" NavigateUrl="CapitalText.aspx?CID=1000321" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031774" Text="0031774   Probation Furniture & Space Efficiency Impr." NavigateUrl="CapitalText.aspx?CID=0031774" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031842" Text="0031842   CHS Facility Modifications" NavigateUrl="CapitalText.aspx?CID=0031842" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002292" Text="1002292   DOCCR Office Safety Audit Modifications" NavigateUrl="CapitalText.aspx?CID=1002292" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031843" Text="0031843   ACF Women's Section Expansion" NavigateUrl="CapitalText.aspx?CID=0031843" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002307" Text="1002307   Hennepin-Ramsey Joint Juvenile Corrections Facility" NavigateUrl="CapitalText.aspx?CID=1002307" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Sheriff" Value="Sheriff">
    <asp:TreeNode Value="0031762" Text="0031762   Sheriffs Holding Area Security Modifications" NavigateUrl="CapitalText.aspx?CID=0031762" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001654" Text="1001654   Sheriff's Enforcement Services Div HQ Facility Mods" NavigateUrl="CapitalText.aspx?CID=1001654" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031775" Text="0031775   Sheriff's Crime Lab Expansion/Remodeling" NavigateUrl="CapitalText.aspx?CID=0031775" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Health" Value="Health">
    <asp:TreeNode Text="North Point Health & Wellness Center" Value="North Point Health & Wellness Center">
    <asp:TreeNode Value="0031735" Text="0031735   North Minneapolis Community Wellness Center" NavigateUrl="CapitalText.aspx?CID=0031735" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Medical Examiner" Value="Medical Examiner">
    <asp:TreeNode Value="1002306" Text="1002306   New Regional Medical Examiner's Facility" NavigateUrl="CapitalText.aspx?CID=1002306" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Medical Center" Value="Medical Center">
    <asp:TreeNode Value="1000323" Text="1000323   HCMC Asset Preservation 2012-2015" NavigateUrl="CapitalText.aspx?CID=1000323" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002163" Text="1002163   HCMC Asset Preservation 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002163" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002512" Text="1002512   HCMC Ambulatory Outpatient Specialty Center" NavigateUrl="CapitalText.aspx?CID=1002512" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031753" Text="0031753   HCMC Simulation Center (and $ placeholder for AOSC)" NavigateUrl="CapitalText.aspx?CID=0031753" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002513" Text="1002513   HCMC Loading Dock Relocation" NavigateUrl="CapitalText.aspx?CID=1002513" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001170" Text="1001170   HCMC In-Patient Bed Consolidation" NavigateUrl="CapitalText.aspx?CID=1001170" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002293" Text="1002293   HCMC Surgery Center Expansion & Relocation" NavigateUrl="CapitalText.aspx?CID=1002293" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001169" Text="1001169   HCMC Blue Building Psychiatric Renovation" NavigateUrl="CapitalText.aspx?CID=1001169" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Health Administration" Value="Health Administration">
    <asp:TreeNode Value="1002160" Text="1002160   1800 Chicago Detox Ctr Refurbishment" NavigateUrl="CapitalText.aspx?CID=1002160" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Human Services" Value="Human Services">
    <asp:TreeNode Text="Human Services & Public Health" Value="Human Services & Public Health">
    <asp:TreeNode Value="1002165" Text="1002165   HSPHD Sobering Ctr Development" NavigateUrl="CapitalText.aspx?CID=1002165" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031821" Text="0031821   HSPHD Satellite Facilities" NavigateUrl="CapitalText.aspx?CID=0031821" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001083" Text="1001083   HSPHD Office Space Reconfiguration" NavigateUrl="CapitalText.aspx?CID=1001083" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001597" Text="1001597   HSPHD South Minneapolis Regional Service Center" NavigateUrl="CapitalText.aspx?CID=1001597" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Information Technology" Value="Information Technology">
    <asp:TreeNode Value="1000325" Text="1000325   IT Community Connections Initiative" NavigateUrl="CapitalText.aspx?CID=1000325" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1002166" Text="1002166   IT Community Connectivity 2016-2020" NavigateUrl="CapitalText.aspx?CID=1002166" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000978" Text="1000978   IT Furniture & Space Efficiency Modifications" NavigateUrl="CapitalText.aspx?CID=1000978" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000979" Text="1000979   IT Data Center Upgrades" NavigateUrl="CapitalText.aspx?CID=1000979" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Resident & Real Estate Services" Value="Resident & Real Estate Services">
    <asp:TreeNode Value="0031794" Text="0031794   HCGC A-5 / A-6 Space Remodeling" NavigateUrl="CapitalText.aspx?CID=0031794" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Municipal Building Commission" Value="Municipal Building Commission">
    <asp:TreeNode Value="0031317" Text="0031317   MBC Life/Safety Improvements" NavigateUrl="CapitalText.aspx?CID=0031317" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031483" Text="0031483   MBC Mechanical Systems Upgrades" NavigateUrl="CapitalText.aspx?CID=0031483" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031715" Text="0031715   MBC Interior Court & Elevator Modifications" NavigateUrl="CapitalText.aspx?CID=0031715" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031847" Text="0031847   MBC Critical Power" NavigateUrl="CapitalText.aspx?CID=0031847" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000935" Text="1000935   MBC Exterior Improvements" NavigateUrl="CapitalText.aspx?CID=1000935" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="0031828" Text="0031828   MBC ADC Plumbing" NavigateUrl="CapitalText.aspx?CID=0031828" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Housing & Redevelopment Authority" Value="Housing & Redevelopment Authority">
    <asp:TreeNode Value="1001950" Text="1001950   Affordable Housing 2014 - 2018" NavigateUrl="CapitalText.aspx?CID=1001950" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001951" Text="1001951   Transit Oriented Development 2014 - 2018" NavigateUrl="CapitalText.aspx?CID=1001951" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1001585" Text="1001585   Strategic Acquisition" NavigateUrl="CapitalText.aspx?CID=1001585" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode Text="Regional Railroad Authority" Value="Regional Railroad Authority">
    <asp:TreeNode Value="1000899" Text="1000899   Southwest LRT Preliminary Engineering" NavigateUrl="CapitalText.aspx?CID=1000899" Target="frame_main"></asp:TreeNode>
    <asp:TreeNode Value="1000941" Text="1000941  Bottineau LRT" NavigateUrl="CapitalText.aspx?CID=1000941" Target="frame_main"></asp:TreeNode>
    </asp:TreeNode>
    </asp:TreeNode>
    </Nodes>
    </asp:TreeView>
    </form>

    <!-- Visual Studio Browser Link -->
    <script type="application/json" id="__browserLink_initializationData">
        {"appName":"Internet Explorer","requestId":"5a18a494e8e9467fac49ce9161940b5b"}
    </script>
    <script type="text/javascript" src="http://localhost:65311/13b018507f1c41668db5e77d50bb8154/browserLink" async="async"></script>
    <!-- End Browser Link -->

    </body>
    </html>

3 个答案:

答案 0 :(得分:4)

您无法以有效的方式创建服务器控件。 <asp:TreeNode>控件不是实际的html元素,所以即使它被推送到客户端,也不会实际显示任何内容。

答案 1 :(得分:1)

Response.Write适用于调试,但对实际生产不利。 您永远不知道何时获得所需的输出。我曾经设法让我的头部在页面的 end 而不是顶部呈现。

将HTML代码移出Response.Write部分,并在需要实际HTML的地方使用纯HTML。 所以,而不是:

Response.Write("<!DOCTYPE html>" + System.Environment.NewLine);

Response.Write("<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">" + System.Environment.NewLine);

使用它:

%>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

只在实际需要的地方切换到编码。

答案 2 :(得分:0)

我认为你不能写出如下行:

Response.Write("<asp:TreeNode Value=\"" + tempArray[8] + "\" Text=\"" + tempArray[4] + "\" NavigateUrl=\"CapitalText.aspx?CID=" + tempArray[8] + "\" Target=\"frame_main\"></asp:TreeNode>" + System.Environment.NewLine);

Response.Write写入响应流,写入的任何内容都将按原样发送到客户端浏览器。由于asp:TreeNode(或应在服务器上处理的任何其他指令)无效html,因此无法获得预期结果。

处理任何asp:*或runat =“server”(在服务器上)并转换为有效的HTML,此HTML将发送到客户端浏览器。