views:

250

answers:

2

I built an empty website on VS 2010. Using the toolbox I put a DataGridView on my default.aspx. Then I configured the sql query that fills it from the DataSource. I wanted to see the ADO code that is done under the covers. But all there is the default.aspx file, and the default.aspx.cs:

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) {}    
}

this is the aspx:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" DataSourceID="SqlDataSource2" ForeColor="#333333" 
        GridLines="None" ondatabound="GridView1_DataBound">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="Title" ...

the web.config:

<configuration>
 <connectionStrings... 
 <system.web>
  <compilation debug="true" targetFramework="4.0"/>
 </system.web>
 <system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
 </system.webServer>
</configuration>

Where did the .designer.cs file gone? Or maybe the aspx markup is all there is? And if so how? And where is the other partial class definition (if I delete the word 'partial' VS won't compile and says that there is another partial class definition) ?

A: 

Have you tried with right click on '_Default' and 'Find all references'?

Fabian
Now that I tried it surprisingly the default.aspx.cs is the only reference!
Hanan
+2  A: 

The other part of the class is generated from the markup (.aspx).

If you want to see the code, a quick way is to first inject an error into the code generated by the markup, using something like <% error %>. After that, when you load the page it will report the error and give you a link you can click on to see the source code.

However, from your example it looks like all the work is being done by the control, not the page itself.

RickNZ
I saw the code lying in 'temporary asp.net'. very cryptic. Anyhow contains some 'build control', 'build tree'..I remember seeing designer.cs files back in the days that had simple code.Anyhow it looks like everything required to handle request for the page is in the .cs files, so I may understand that the aspx code is just a markup that get parsed to .net code and then not used anymore as code to handle page request?
Hanan
Yes, the markup file gets parsed to .NET code. The generated code registers any controls on the page in the control tree, so they can receive events as the page is processed. All "plain" markup is inserted into `<asp:Literal>` controls. All controls write their output to the client during the Render phase of page processing.
RickNZ