why m i getting this error "The name 'lblHelloWorld' does not exist in the current context"? How do i fix it?
<%# Page Language="C#" AutoEventWireup="True" Inherits="_Default" Codebehind="Default.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Hello, world!</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="MainScriptManager" runat="server" />
<asp:UpdatePanel ID="pnlHelloWorld" runat="server">
<ContentTemplate>
<asp:Label runat="server" ID="lblHelloWorld" Text="Click the button!" />
<br /><br />
<asp:Button runat="server" ID="btnHelloWorld" OnClick="btnHelloWorld_Click" Text="Update label!" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ajaxTesting
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnHelloWorld_Click(object sender, EventArgs e)
{
lblHelloWorld.Text = "Hello, world - this is a fresh message from ASP.NET AJAX! The time right now is: " + DateTime.Now.ToLongTimeString();
}
}
}
I tried cleaning and rebuliding; deleting the designer.cs file and recreating it but was of no use.
I think the problem in your designer.cs file.Try to add a reference manually for this label in the designer.cs file.
EDIT:
The problem after revision to your code is in the name space.
To fix your problem::
Replace your line by this:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ajaxTesting._Default" %>
The Best possible solution would be:
Copy all the lines of code between <body> and </body>
Create a new aspx page in your project.
Replace the <body> tag with the one you copied
Similarly copy and paste the code from .cs file also.
I feel this should solve your problem.
Step 1:
Copy off the aspx form, codebehind and designer files and re-create the form again by copying and pasting.
Step 2:
If step 1 doesn't fix it: In visual Studio, go to Edit -> Find and Replace -> Find in Files and search within your project for a control with the same name.
Step 3
Close out Visual Studio and all browsers. Temporarily stop IIS and navigate to the temp ASP.NET files folder (the path may be different on your machine):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Start deleting everything from the site folder in here, starting at the bottom (because you may get ACL folder permission restrictions).
Re-start IIS and try again (after you have tried one or both of previous steps).
Another possibility that I had:
If you duplicate the .cs file, for example: duplicate "Default.aspx.cs", getting "Default.aspx - Copy.cs" (now you have the two files on the same folder),
the result will be: the file will appear in the project file list. Even excluding the copied file out of the project, but leave the file on the same folder will not solve the problem.
In order to avoid this issue, remove the copied file out of the project folders.
I had this problem after importing source files from someone else. After a while I discovered I didn't have any designer.cs file.
I followed this solution. Especially the part about "Convert to Web Application". That did the trick for me!
I faced this same problem in asp.net website (3.5) In my case there were 2 copies of the same file.
Compute.aspx
Compute_backup.aspx
I excluded the #2 file from the website and it worked for me.
I completely removed the apex file a re-created it and left to object name _Default. I then set about adjusting the C# code accordingly and voila, it worked OK. This was when working with ASP.NET 3.5 in VS2008. In this case I got it to work, but there is still something funky about VS2008 or this would not be necessary.
Related
I've got a weird issue in Visual Studio where I can't reference controls from the code-behind page.
To give a really simple example, my page is like this:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="New.aspx.cs" Inherits="ITDashboard.idea.New" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
And my codebehind is this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ITDashboard.idea
{
public partial class New : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "hello";
}
}
}
The application is called ITDashboard, and this page is in a folder called "idea".
Have looked around, and some posts suggest deleting the designer file and recreating it. However, there's no option in VS2012 that I could see. Also I get the same error with a new blank page, even at the site root.
I don't have enough points yet to add a comment, so please forgive this comment in the answer box!
I've seen this before. "This" = VS not adding controls to the designer file. From what I was able to find, it's just a corruption in the page. Or if it's happening on all pages, it's a corruption of the project. You didn't do anything to cause it, so there is nothing you can do in the future to avoid it. Luckily, in 13+ years of working with various versions of VS, I've only seen it two or three times.
Andrew nailed it. If the problem is isolated to this page, then create a new page and replicate your corrupt page one control at a time. If it's at the project level (and it sounds like it is), you'll have a little more work to do.
Here's a good tip on how to recover from a corrupt project:
How can I recover a corrupt .csproj file in Visual Studio 2010?
Good luck!
Thought I'd post in case somebody has the same thing.
All the web posts I saw were pointing to "Convert to web application" (now under Project in VS2013). However this wasn't working for me.
Finally got it working by changing the .net Framework type (arbitrarily to 4.5). I then re-ran the Convert to web application option and it recreated the designer.cs files.
Also, any new controls I add are automatically added to the designer.cs properly now.
if you are having redouble setting the text of Label1 ...change Label1.text to Label1.Text.
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'label1' does not exist in the current context ConsoleApplication6
I am having one of the weirdEST issue I have ever faced. Its ridiculous.
Server side comments gets added as a LiteralControl to the original container control. I know it sounds really crazy, but thats what I am experiencing here :(
My environment: Visual studio 2012, IIS 7, .net frameworks 4.0
I am copying my test page here:
Default.aspx page:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div runat="server" id="divTest">
<%--test--%>
<%--test--%>
</div>
</form>
</body>
</html>
Default.aspx.cs:
using System;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(string.Format("divTest Control count: {0}", divTest.Controls.Count));
}
}
web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>
The resulting page shows the output:
divTest Control count: 3
The funniest part is that, I tried to run this same page in 3 other boxes,( with exactly same config/environment) and it worked as expected in 2 of them and the other one showed the same result as mine. Again, if I change the build target framework version to 2.0, it shows the expected results (divTest Control count: 1). This happens only when I build it in 4.0
Any idea what could be the reason for this odd behaviour? Am i missing something here?
Thanks
Benjamin
The extra LiteralControl is not from comment but white spaces that surrounds it.
Same thing happend to me when switched from VS.NET 2010 to 2013 (yes, just upgraded VS.NET - no change in website target framework - 4.0)
The solution in my case was to use FindControl() method instead of accessing ControlCollection directly by index.
I have two files named as TimeSheet.aspx.cs and TimSheet.aspx ,code of the file are given below for your reference.
when i build the application im getting error "The name 'GridView1' does not exist in the current context" even thought i have a control with the id GridView1 and i have added the runat="server" as well.
Im not able to figure out what is causing this issue.Can any one figure whats happen here.
Thanks & Regards,
=======================================
TimeSheet.aspx.cs
=======================================
#region Using directives
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSMS.Web.UI;
#endregion
public partial class TimeSheets: Page
{
protected void Page_Load(object sender, EventArgs e)
{
FormUtil.RedirectAfterUpdate(GridView1, "TimeSheets.aspx?page={0}");
FormUtil.SetPageIndex(GridView1, "page");
FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string urlParams = string.Format("TimeSheetId={0}", GridView1.SelectedDataKey.Values[0]);
Response.Redirect("TimeSheetsEdit.aspx?" + urlParams, true);
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
}
}
=======================================================
TimeSheet.aspx
=======================================================
<%# Page Language="C#" Theme="Default" MasterPageFile="~/MasterPages/admin.master" AutoEventWireup="true" CodeFile="TimeSheets.aspx.cs" Inherits="TimeSheets" Title="TimeSheets List" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">Time Sheets List</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1" PersistenceMethod="Session" />
<br />
<data:EntityGridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
DataSourceID="TimeSheetsDataSource"
DataKeyNames="TimeSheetId"
AllowMultiColumnSorting="false"
DefaultSortColumnName=""
DefaultSortDirection="Ascending"
ExcelExportFileName="Export_TimeSheets.xls" onrowcommand="GridView1_RowCommand"
>
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="True" />
<asp:BoundField DataField="TimeSheetId" HeaderText="Time Sheet Id" SortExpression="[TimeSheetID]" ReadOnly="True" />
<asp:BoundField DataField="TimeSheetTitle" HeaderText="Time Sheet Title" SortExpression="[TimeSheetTitle]" />
<asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Start Date" SortExpression="[StartDate]" />
<asp:BoundField DataField="EndDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="End Date" SortExpression="[EndDate]" />
<asp:BoundField DataField="DateOfCreation" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Date Of Creation" SortExpression="[DateOfCreation]" />
<data:BoundRadioButtonField DataField="Locked" HeaderText="Locked" SortExpression="[Locked]" />
<asp:BoundField DataField="ReviewedBy" HeaderText="Reviewed By" SortExpression="[ReviewedBy]" />
<data:HyperLinkField HeaderText="Employee Id" DataNavigateUrlFormatString="EmployeesEdit.aspx?EmployeeId={0}" DataNavigateUrlFields="EmployeeId" DataContainer="EmployeeIdSource" DataTextField="LastName" />
</Columns>
<EmptyDataTemplate>
<b>No TimeSheets Found!</b>
</EmptyDataTemplate>
</data:EntityGridView>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
<br />
<asp:Button runat="server" ID="btnTimeSheets" OnClientClick="javascript:location.href='TimeSheetsEdit.aspx'; return false;" Text="Add New"></asp:Button>
<data:TimeSheetsDataSource ID="TimeSheetsDataSource" runat="server"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
EnableDeepLoad="True"
>
<DeepLoadProperties Method="IncludeChildren" Recursive="False">
<Types>
<data:TimeSheetsProperty Name="Employees"/>
<%--<data:TimeSheetsProperty Name="TimeSheetDetailsCollection" />--%>
</Types>
</DeepLoadProperties>
<Parameters>
<data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
<asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex" Type="Int32" />
<asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize" Type="Int32" />
<data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
</Parameters>
</data:TimeSheetsDataSource>
</asp:Content>
Problem can be that GridView1 is not automatically added in designer.cs file. If that is case add it in designer manually.
Assuming a WebSite project verify that when building it you do not get Warnings like:
Generation of designer file failed: [Failure Reason]
It seems that you're not registering the custom control EntityGridView. See the Register directive to see how you can do it.
I've had this problem before when I've 'added' an existing file (.aspx + .aspx.cs) to a project and the designer file hasn't updated itself. I've tried many/all of the things written here, but I find that creating a new file, copying the code-front code in, then the code-behind and then rebuilding essentially does the trick. Yes, it's a pain in the * depending on the size of the file(s) you're working with, but this typically happens when I want to quickly test some demo code I've come across (some new project etc.) and throw it into my local VS.
It is nested, so some things don't happen automatically.
You might have to manually add it to the designer, or else (in VB) explicitly use the handles keyword or (in C#) explicitly wire up with "+=" operator.
Make sure all events or explicitly stated in the control mark-up
Since I see you list the event explicitly, I'd check the designer.
I had this same problem in Visual Studio 2010. The design.cs file was correctly generated. I closed Visual Studio, and reopened it. This resolved this issue for me (after much frustration).
I don't know if this will help, but I've been fighting with a similar situation.
The situation: I have included some code from the modified some of the templated asp.net web project into my project - specifically the login markup. For some reason, one of the "UserName" Textbox control refuses to be recognized in the designer. Strangely enough, the "UserNameLabel" control on the next line of markup is recognized:
<%# Page Language="C#" AutoEventWireup="True" CodeBehind="Logon.aspx.cs" MasterPageFile="~/Site.master" Inherits="SimpleWebApp.Logon" %>
<asp:Content ID="LogonRegister" ContentPlaceHolderID="MainContent" runat="server">
<div></div>
<table align="center">
<tr>
<td valign="top">
*<asp:TextBox ID="TextBox1" runat="server" CssClass="textEntry"></asp:TextBox>*
<asp:Login ID="LoginUser" runat="server" EnableViewState="true" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"/>
<div class="accountInfo">
<fieldset class="login">
<legend>Log In</legend>
<p>
**<asp:Label ID="lblUserNameLabel" runat="server">Username:</asp:Label>**
***<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>***
</p>
...
What I've tried:
I've restarted VWD 2010,
deleted the designer file and recreated it through converting the page to a web application
changed the name of the Textbox,
deleted and recreated the Textbox.
I decided to experiment a little, and discovered that adding a typical textbox just outside the asp:Login tag is recognized, while adding it just inside that tag leaves it unrecognized in the designer.
Figured this might help myself or someone else to piece together what might be going on.
Anyone have any idea what might cause this behavior around the asp:Login tag?
For closely related answers, visit a slightly similar question, How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?.
#sameer: I'd be interested to hear if you tried to replace CodeFile="TimeSheets.aspx.cs" with CodeBehind="TimeSheets.aspx.cs" before converting the project.
I know this is an old thread, but I just struggled with an issue similar to this. After a couple of days, I figured out that I had a backup copy of the problem page and code behind in my project. I kept getting the error "does not exist in the current context" at compile time on objects placed on the new page, even though intellisense recognized them. I guess VS was getting confused because of the duplicate pages in the default namespace. Once I got rid of the backup, I magically stopped getting the errors.
I had the same problem, none of the solutions worked for me. I figured out without wasting too much time, that many of the ASPX pages in the Admin section were being given the same class name as the entities in the project entity files. Also, each of the pages listed the Entities namespace causing conflicts since after adding the entity namespace in the using directives, there were namespace conflicts. I went through and added "Page" to each of the ASPX page, recompiled and everything worked fine.
I know this thread has already been answered, but I wanted to include this description in case there are others that have this same problem and none of the above solutions worked, to give them something else that might be the issue.
I had 21 pages to change in my project, here is an example using the UserEntity and the Admin/UserEntity.aspx:
in UsersEntity.aspx front side aspx page, changed:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntity"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
to:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntityPage"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
in the UsersEntity.aspx.cs code behind, I changed:
public partial class UsersEntity : System.Web.UI.Page
to:
public partial class UsersEntityEntityPage : System.Web.UI.Page
and in the UsersEntity.aspx.designer.cs (Designer Page):
That page got automatically changed when I changed the code behind page to:
public partial class UsersEntityPage {
I did that for each of the other offending pages, which were all of them except for the "Edit" pages.
-- I guess I could have just removed the using directive to the Entity name space, but I really want to be able to have access to that in my pages, plus I think it is ungood for the page classes to have the exact same name as my entity classes. It causes confusion to me to have it like that.
copy the _.aspx file code and paste it on the _.aspx.cs page.
if it is not then import namespaces all the way top.
<%# Page Language="C#" AutoEventWireup="true" %> <%# Import
Namespace="System.Data" %> <%# Import
Namespace="System.Data.SqlClient" %>
I found that there was an incorrect file reference name in the designer.cs file. It was the code filename with a 1 added to the end. I removed the 1 and the code ran without error. Prior to this I deleted and rebuilt the designer file without resolution.
The easiest way is to:
Delete the designer file (YourFilename.aspx.designer.cs)
Select the ASPX file in Solution Explorer
Under Projects menu look for the item "Convert to Web Application" and click on it. Click Yes on the dialog window.
Open up the newly created designer file and make sure the namespace matches the namespace on the primary aspx.cs file (VERY IMPORTANT)
Close the designer file.
Save the solution. Close it and then reopen.
I've been struggling with some issues relating to referencing child controls within a FormView. Another developer wrote an ASPX page that is compiling and working and in that code, he references child controls within a FormView directly as properties of the page object. The page is part of an ASP.NET Web SITE Project (as opposed to a Web Application Project). We decided to convert the project to the Web Application Project model and noticed that these property references now don't compile. The code behind file does not generate the controls within the form view.
While researching that issue (I had a separate post here regarding those problems), I came across something baffling. From all the posts I've read, you should always need to reference child controls within a FormView's template using FindControl -- i.e. it is supposedly not possible to do through a simple generated property regardless of whether you're in the Web Site Project model or the Web Application Project model.
I was puzzled as to how my colleague's code compiled and ran. As I indicated, he is referencing the FormView's contained child controls through simple properties in the page and did not have to resort to FindControl calls. So to get to the bottom of this mystery, I cooked up the shortest example that demonstrates this phenomenon.
What I found was very strange. The code I have here has a ASP:FormView with a few label controls within it's ItemTemplate. One of those labels has the ID MyComment. When the FormView databinds (to the Northwind's Products table), I simply set some text.
using System;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.FormView1.ChangeMode(FormViewMode.ReadOnly);
}
protected void FormView1_DataBound(object sender, EventArgs e) {
MyComment.Text = "Data bound at " + DateTime.Now.ToString();
}
}
This code will not compile because MyComment is not a valid property. Here comes the strange part. If I embed within the FormView's ItemTemplate a TabContainer control from the Ajax Control Toolkit library, the code above does compile and runs correctly.
So the reason my colleague's code is compiling is because of the embedded TabContainer control within the FormView?? Why this should change the behavior of the compiler and the mechanisms by which you can get access to the FormView's child controls is a mystery to me. Incidentally, despite the fact that it compiles cleanly and runs correctly, Intellisense does not see these properties and ReSharper reports them as compile errors (by the red light in the indicator bar).
Here is the markup for the page. Can anyone shed some light on this behavior? Incidentally, I'm not complaining about the fact that ASP.NET creates these properties in this circumstance. (Unfortunately, this happy, but strange, behavior, only seems to apply if the project is a Web Site Project; as a Web Application Project, property accessors don't work within the FormView even with the embedded TabControl).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"
OnDataBound="FormView1_DataBound">
<ItemTemplate>
<ajaxToolkit:TabContainer runat="server" ID="TabsItem">
<ajaxToolkit:TabPanel runat="Server" ID="PanelBasicsItem" HeaderText="Basics">
<ContentTemplate>
ProductID:
<asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
<br />
ProductName:
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Bind("ProductName") %>' />
<br />
My Comment:
<asp:Label ID="MyComment" runat="server"></asp:Label>
<br />
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
When you converted the Web site to a web application, did you check that the partial classes were correctly generated for your aspx files (e.g. there should be a file called "Default.aspx.cs.designer" in your web application, under the Default.aspx and Default.aspx.cs files).
In a web site, these are generated on the fly by the server as your site runs and is compiled (and so don't exist in your project), while in a web application they are created and managed by Visual Studio - if they don't exist, then the code will potentially fail to compile because the objects haven't been instatiated - what is the actual compiler error are you seeing?
By adding a new control to the page after you've converted the project to a web application, you are forcing VS to create the partial class that was missing.
Is there a way to execute a full ASPX source file where the page source is from a string/database/resource and not a file on the file system? It's straightfoward to render dynamic content/images/etc using HTTP Handlers and Modules and writing to the Response, but there doesn't seem to be a way to execute/compile ASPX source without a file on the file system. For example:
HttpContext.Current.Server.Execute() overloads require a path to a file
System.Web.Compilation.BuildManager can only create from a virtual path
The goal is to be able to execute a string source like the following from a Handler/Module/ViewEngine and not require a file on the file system (but get the source from another location):
<%# Page language="C#" MasterPageFile="~/Shared/Site.Master" Inherits="System.Web.UI.Page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListView Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Example</h3>
<asp:ListView ID="List" runat="server" DataSourceID="ProductDataSource">
<LayoutTemplate><ol><asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder></ol></LayoutTemplate>
<ItemTemplate><li><%# Eval("ProductName") %></li></ItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="ProductDataSource" runat="server"DataFile="~/App_Data/Northwind.mdb"SelectCommand="SELECT [ProductName], [QuantityPerUnit], [UnitPrice], [CategoryName] FROM [Alphabetical List of Products]"></asp:AccessDataSource>
</form>
</body>
</html>
(NOTE: The sample above is just a simple example, but shows using server controls, data binding syntax, a master page and possible user control declarations in page directives, etc...)
I hope this makes sense!
Perhaps you need a virtual path provider. It allows you to store the ASPX and codebehind in different media - RDBMS, xml file etc.
Update: Check the post by korchev using virtualpathprovider, which is more suited for this scenario.
Can you use a dummy file with a place holder literal control and replace the literal control with the actual source?
These might not be useful but posting couple of links I found:
Loading an ASP.NET Page Class dynamically in an HttpHandler
How To: Dynamically Load A Page For Processing
I knew that SharePoint Server used to keep the ASPX pages in the database and not on the file system. Details, however, I do not hold.