Displaying sourcecode when clicking a button
<p>First I have to let you know that i am a newbie in this area, learning from tutorials.</p>

<p>With that said I'm looking for a way to load sourcecode from the codebehind file into a textbox, when clicking a button. Same goes for the aspx file.</p>

<p>Im making this website, where i am going to show code examples from what im doing. So if I navigate to myweb.com/tutorial1done.aspx this page would show me the final result from the tutorial done. When i click the show source button it should make 2 textboxes visible, and add the codebehind to the first box, and the aspx source to the second box.</p>

<p>I don't know if it is possible, but I am hoping so.</p>

<p>This far i have this:</p>

<p>ASPX: </p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DateTimeOutput.aspx.cs" Inherits="WebApplication1.DateTimeOutput" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
&lt;title&gt;&lt;/title&gt;
&lt;link rel="stylesheet" href="../styles/codeformatter.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;customControls:Header runat="server" heading="Date and Time Output" /&gt;
&lt;div&gt;
    &lt;asp:Panel ID="Panel1" runat="server"&gt;
        &lt;asp:TextBox ID="outputText" runat="server" Height="175px" TextMode="MultiLine" 
            Width="400px"&gt;&lt;/asp:TextBox&gt;
    &lt;/asp:Panel&gt;
&lt;/div&gt;
&lt;asp:Panel ID="Panel2" runat="server"&gt;
    &lt;asp:Button ID="runButton" runat="server" Text="Run Code" 
        onclick="runButton_Click" Width="95px" /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
    &lt;asp:Button ID="clearButton" runat="server" Text="Clear Console" 
        onclick="clearButton_Click" Width="95px" /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;asp:Button ID="dt_showSource_btn" runat="server" 
        onclick="dt_showSource_btn_Click" Text="Show Source" /&gt;
&lt;/asp:Panel&gt;
&lt;asp:Label ID="dtLabel1" runat="server" Text="Code Behind:" Visible="False"&gt;&lt;/asp:Label&gt;
&lt;br /&gt;
&lt;asp:TextBox ID="dtcb_output" runat="server" Height="175px" 
    TextMode="MultiLine" Visible="False" Width="400px"&gt;&lt;/asp:TextBox&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;asp:Label ID="dtLabel2" runat="server" Text="ASPX:" Visible="False"&gt;&lt;/asp:Label&gt;
&lt;br /&gt;
&lt;asp:TextBox ID="dtaspx_output" runat="server" Height="175px" 
    TextMode="MultiLine" Visible="False" Width="400px"&gt;&lt;/asp:TextBox&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>And the Codebehind:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class DateTimeOutput : System.Web.UI.Page
    {
    protected void output(String value)
    {
        outputText.Text += value + Environment.NewLine;
    }

    protected void runButton_Click(object sender, EventArgs e)
    {
        DateTime dt = new DateTime();
        output(dt.ToString());
        DateTime nowDt = DateTime.Now;
        output(nowDt.ToString());
    }

    protected void clearButton_Click(object sender, EventArgs e)
    {
        outputText.Text = "";
    }

    protected void dt_showSource_btn_Click(object sender, EventArgs e)
    {
        if (dtcb_output.Visible == false)
        {
            dtLabel1.Visible = true;
            dtcb_output.Visible = true;
        }
        else
        {
            dtLabel1.Visible = false;
            dtcb_output.Visible = false;
        }

        if (dtaspx_output.Visible == false)
        {
            dtLabel2.Visible = true;
            dtaspx_output.Visible = true;
        }
        else
        {
            dtLabel2.Visible = false;
            dtaspx_output.Visible = false;
        }

    }

}
}
</code></pre>

<p>For now source highlighting is not needed, unless its easy to do.</p>

<p>Thx in advance.</p>
