I would like to customise the List page to display only some fields in the grid view for a particular table. That is what I have done:
1 - Created a folder under CustomPages folder called tblUsers (my table name is tblUser and the entity set name is tblUsers)
2 - I copied the List.aspx from the PageTemplates folder into the CustomPages/tblUsers I created.
CustomPages/tblUsers/List.aspx
However, the application does not compile any more. I think there is a conflict with the names in the file I copied. I get a lot of errors.
Please can someone shed some light on how to fix this? I saw a talk by David where he justed copied the List.aspx to the new folder and everything just worked. Why this is not working for me?
Error 1 The type 'MarsUsersAdmin.List' already contains a definition for 'table' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 14 29 MarsUsersAdmin
Error 2 Type 'MarsUsersAdmin.List' already defines a member called 'Page_Init' with the same parameter types C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 16 24 MarsUsersAdmin
Error 3 The type 'MarsUsersAdmin.List' already contains a definition for 'headContent' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 18 61 MarsUsersAdmin
Error 12 The type 'MarsUsersAdmin.List' already contains a definition for 'GridView1' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 34 62 MarsUsersAdmin
namespace MarsUsersAdmin.tblUser
{
public partial class List : System.Web.UI.Page
{
What have I done wrong?
Cheers
Server Error in '/' Application.
The resource cannot be found.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
The problem is that you're trying to request the custom page directly (/DynamicData/CustomPages/tblUsers/List.aspx). Instead, the idea of Custom Pages is that you keep on making the same request as before you had the custom page, but you'll end up having
it override the Page Template.
e.g. here you probably want to request /tblUsers/List.aspx
Marked as answer by pallone on Feb 06, 2012 11:00 AM
yes, I changed the namespace as Steve mentioned and the application builds ok but then I get the 404 error as the file did not exists.
I do not know how to fix this. Why DD is not able to find the new folder and file under the CustomPages folder?
But in your MIX08 talk you did not have to change the namespace after copying the List.aspx file under the new folder and it just worked.
I also have some sample code from another source and I have checked the List.aspx that he copied under the CustomPages/Companies folder and it works fine. He did not have to change the namespace at all.
I was wondering if this caused because I am using a Web application and his demo uses a Web Site. Also I put my EF model under a folder called DAL.
pallone
Member
165 Points
160 Posts
CustomPages not working
Feb 03, 2012 03:07 PM|LINK
Hi,
I created an ASP.NET Dynamic Data Web Application
I would like to customise the List page to display only some fields in the grid view for a particular table. That is what I have done:
1 - Created a folder under CustomPages folder called tblUsers (my table name is tblUser and the entity set name is tblUsers)
2 - I copied the List.aspx from the PageTemplates folder into the CustomPages/tblUsers I created.
CustomPages/tblUsers/List.aspx
However, the application does not compile any more. I think there is a conflict with the names in the file I copied. I get a lot of errors.
Please can someone shed some light on how to fix this? I saw a talk by David where he justed copied the List.aspx to the new folder and everything just worked. Why this is not working for me?
Error 1 The type 'MarsUsersAdmin.List' already contains a definition for 'table' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 14 29 MarsUsersAdmin
Error 2 Type 'MarsUsersAdmin.List' already defines a member called 'Page_Init' with the same parameter types C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 16 24 MarsUsersAdmin
Error 3 The type 'MarsUsersAdmin.List' already contains a definition for 'headContent' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 18 61 MarsUsersAdmin
Error 12 The type 'MarsUsersAdmin.List' already contains a definition for 'GridView1' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 34 62 MarsUsersAdmin
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: CustomPages not working
Feb 03, 2012 03:20 PM|LINK
Simple solution Pallone, you need to change the namespace on the page you copied what I usually do is:
in the .aspx page
in the .cs file
namespace Northwind.TableNamehope that helps, this is normal in any Web Application project and does not happen in Website project.
Always seeking an elegant solution.
pallone
Member
165 Points
160 Posts
Re: CustomPages not working
Feb 03, 2012 04:47 PM|LINK
Hi sjnaughton,
Thanks.
This is strange because I have a demo where this is working and the namespace is the same in the page I copied.
I will try to change the name and see what happens. By the way, do I have to use the table name or entity set name for the folder?
pallone
Member
165 Points
160 Posts
Re: CustomPages not working
Feb 03, 2012 04:59 PM|LINK
Hi,
I have changed the namespace as you suggested but now I get a 404 error. This is how I changed it:
tblUser = table name
tblUsers = Entity Set name
<%
@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="MarsUsersAdmin.tblUser.List"
%>
namespace MarsUsersAdmin.tblUser
{
public partial class List : System.Web.UI.Page
{
What have I done wrong?
Cheers
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /DynamicData/CustomPages/tblUsers/List.aspx
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: CustomPages not working
Feb 03, 2012 05:13 PM|LINK
the folder name should also be the plural name of the table the namespace dose not matter, it just has to be unique.
Always seeking an elegant solution.
pallone
Member
165 Points
160 Posts
Re: CustomPages not working
Feb 03, 2012 05:30 PM|LINK
This is exactly what I did but it is still not working.
MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: CustomPages not working
Feb 04, 2012 06:24 AM|LINK
The problem is that you're trying to request the custom page directly (/DynamicData/CustomPages/tblUsers/List.aspx). Instead, the idea of Custom Pages is that you keep on making the same request as before you had the custom page, but you'll end up having it override the Page Template.
e.g. here you probably want to request /tblUsers/List.aspx
pallone
Member
165 Points
160 Posts
Re: CustomPages not working
Feb 04, 2012 07:34 PM|LINK
Hi David,
I have not changed anytying in the application. I just followed your MIX08 talk and copied the List.aspx page to the CustomPages/tblUsers/List.aspx.
However, after I do that the application does not build. I get a lot of namespaces conflict which you did not get in the talk.
Could you please shed some light why this is happening to me?
Cheers
Claudio
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: CustomPages not working
Feb 04, 2012 07:57 PM|LINK
Claudio, I think we're talking about two unrelated things here. :)
Your initial issue was caused by keeping the same namespace as Steve mentioned. I assumed this was resolved.
My response was to the follow up 404 error.
pallone
Member
165 Points
160 Posts
Re: CustomPages not working
Feb 04, 2012 11:56 PM|LINK
Hi David,
yes, I changed the namespace as Steve mentioned and the application builds ok but then I get the 404 error as the file did not exists.
I do not know how to fix this. Why DD is not able to find the new folder and file under the CustomPages folder?
But in your MIX08 talk you did not have to change the namespace after copying the List.aspx file under the new folder and it just worked.
I also have some sample code from another source and I have checked the List.aspx that he copied under the CustomPages/Companies folder and it works fine. He did not have to change the namespace at all.
I was wondering if this caused because I am using a Web application and his demo uses a Web Site. Also I put my EF model under a folder called DAL.
Cheers
C