CustomPages not workinghttp://forums.asp.net/t/1765641.aspx/1?CustomPages+not+workingMon, 06 Feb 2012 19:29:20 -050017656414815049http://forums.asp.net/p/1765641/4815049.aspx/1?CustomPages+not+workingCustomPages not working <p>Hi,</p> <p>I created an ASP.NET Dynamic Data Web Application</p> <p>I would like to customise the&nbsp;List page to display only some fields in the grid view for a particular table. That is what I have done:</p> <p>1 - Created a folder under CustomPages folder called tblUsers (my table name is tblUser and the entity set name is tblUsers)</p> <p>2 - I copied the List.aspx from the PageTemplates folder into the CustomPages/tblUsers I created.</p> <p>CustomPages/tblUsers/List.aspx</p> <p>However, the application <strong>does not compile any more</strong>. I think there is a conflict with the names in the file I copied. I get a lot of errors.</p> <p><strong>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?</strong></p> <p>Error&nbsp;1&nbsp;The type 'MarsUsersAdmin.List' already contains a definition for 'table'&nbsp;C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs&nbsp;14&nbsp;29&nbsp;MarsUsersAdmin</p> <p>Error&nbsp;2&nbsp;Type 'MarsUsersAdmin.List' already defines a member called 'Page_Init' with the same parameter types&nbsp;C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs&nbsp;16&nbsp;24&nbsp;MarsUsersAdmin</p> <p>Error&nbsp;3&nbsp;The type 'MarsUsersAdmin.List' already contains a definition for 'headContent'&nbsp;C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs&nbsp;18&nbsp;61&nbsp;MarsUsersAdmin</p> <p>Error&nbsp;12&nbsp;The type 'MarsUsersAdmin.List' already contains a definition for 'GridView1'&nbsp;C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs&nbsp;34&nbsp;62&nbsp;MarsUsersAdmin</p> 2012-02-03T15:07:14-05:004815083http://forums.asp.net/p/1765641/4815083.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Simple solution Pallone, you need to change the namespace on the page you copied what I usually do is:</p> <p>in the .aspx page</p> <pre style="background:white; color:black; font-family:Consolas"><span style="background:yellow">&lt;%</span><span style="color:blue">@</span>&nbsp;<span style="color:maroon">Page</span>&nbsp;<span style="color:red">Language</span><span style="color:blue">=</span><span style="color:blue">&quot;C#&quot;</span>&nbsp;<span style="color:red">MasterPageFile</span><span style="color:blue">=</span><span style="color:blue">&quot;~/Site.master&quot;</span>&nbsp;<span style="color:red">CodeBehind</span><span style="color:blue">=</span><span style="color:blue">&quot;List.aspx.cs&quot;</span>&nbsp;<span style="color:red">Inherits</span><span style="color:blue">=</span><span style="color:blue">&quot;Northwind.TableName.List&quot;</span>&nbsp;<span style="background:yellow">%&gt;</span> </pre> <p>in the .cs file</p> <pre style="background:white; color:black; font-family:Consolas"><span style="color:blue">namespace</span>&nbsp;Northwind.TableName </pre> <p>hope that helps, this is normal in any Web Application project and does not happen in Website project.</p> 2012-02-03T15:20:53-05:004815240http://forums.asp.net/p/1765641/4815240.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi sjnaughton,</p> <p>Thanks.</p> <p>This is strange because I have a demo where this is working and the namespace is the same in the page I copied.</p> <p>I will try to change the name and see what happens. By the way, <strong>do I have to use the table name or entity set name for the folder?</strong></p> <p>&nbsp;</p> 2012-02-03T16:47:12-05:004815255http://forums.asp.net/p/1765641/4815255.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi,</p> <p>I have changed the namespace as you suggested but now I get a 404 error. This is how I changed it:</p> <p><strong>tblUser</strong> = table name</p> <p><strong>tblUsers</strong> = Entity Set name</p> <p>&lt;%</p> <p>@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/Site.master&quot; CodeBehind=&quot;List.aspx.cs&quot; Inherits=&quot;<strong>MarsUsersAdmin.tblUser.List</strong>&quot;</p> <p>%&gt;</p> <p>&nbsp;<span><span>namespace <strong>MarsUsersAdmin.tblUser</strong><br> {<br> &nbsp;&nbsp;&nbsp; public partial class List : System.Web.UI.Page<br> &nbsp;&nbsp;&nbsp; {&nbsp;</span></span></p> <p><span><span></span></span><strong><span style="text-decoration:underline">&nbsp;What have I done wrong?</span> </strong></p> <p>Cheers</p> <p><span><span></span></span>&nbsp;</p> <h1>Server Error in '/' Application.</h1> <hr color="silver" size="1" width="100%"> <h2><i>The resource cannot be found.</i></h2> <p><span face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif " style="font-family:Arial,Helvetica,Geneva,SunSans-Regular,sans-serif"><span face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif " style="font-family:Arial,Helvetica,Geneva,SunSans-Regular,sans-serif"><b>Description: </b>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. &nbsp;Please review the following URL and make sure that it is spelled correctly. <br> <br> <b>Requested URL: </b>/DynamicData/CustomPages/tblUsers/List.aspx<br> <br> </span></span></p> <hr color="silver" size="1" width="100%"> <p><span face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif " style="font-family:Arial,Helvetica,Geneva,SunSans-Regular,sans-serif"><b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 </span></p> 2012-02-03T16:59:26-05:004815284http://forums.asp.net/p/1765641/4815284.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>the folder name should also be the plural name of the table the namespace dose not matter, it just has to be unique.</p> 2012-02-03T17:13:19-05:004815312http://forums.asp.net/p/1765641/4815312.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>This is exactly what I did but it is still not working.</p> <p>MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx</p> 2012-02-03T17:30:45-05:004815916http://forums.asp.net/p/1765641/4815916.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>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.</p> <p>e.g. here you probably want to request&nbsp;/tblUsers/List.aspx</p> 2012-02-04T06:24:46-05:004816547http://forums.asp.net/p/1765641/4816547.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi David,</p> <p>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.</p> <p>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.</p> <p>Could you please shed some light why this is happening to me?</p> <p>Cheers</p> <p>Claudio</p> <p>&nbsp;</p> <p>&nbsp;</p> 2012-02-04T19:34:03-05:004816560http://forums.asp.net/p/1765641/4816560.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Claudio, I think we're talking about two unrelated things here. :)</p> <p>Your initial issue was caused by keeping the same namespace as Steve mentioned. I assumed this was resolved.</p> <p>My response was to the follow up 404 error.</p> 2012-02-04T19:57:26-05:004816661http://forums.asp.net/p/1765641/4816661.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi David,</p> <p>yes, I changed the namespace as Steve mentioned and the <strong>application builds ok but then I get the 404 error as the file did not exists.</strong></p> <p>I do not know how to fix this. Why DD is not able to find the new folder and file under the CustomPages folder?</p> <p>But in your <strong>MIX08 talk</strong> you <strong>did not have to change the namespace after copying the List.aspx file under the new folder and it just worked.</strong></p> <p><span style="text-decoration:underline"><strong>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.</strong></span></p> <p><strong>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.</strong></p> <p><strong>Cheers</strong></p> <p><strong>C</strong></p> <p>&nbsp;</p> 2012-02-04T23:56:35-05:004816666http://forums.asp.net/p/1765641/4816666.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>For the namespace conflict, yes, WAP vs Web Site is the difference. In WAPs, all the code behind sources get compiled in the same assembly, so you can't have conflict. In Sites, they each end up in separate assemblies, so it doesn't matter.</p> <p>For the 404 issue, please see my initial answer to this thread. We need to understand exactly what URL you requested.</p> 2012-02-05T00:10:27-05:004817145http://forums.asp.net/p/1765641/4817145.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>yes you will have issues if you move files between Web Application Project and Website projects, as there are a few differences between the files.</p> <p>Can you post the URL you are using to access hte custom page as we may have another issue :)</p> 2012-02-05T14:36:03-05:004817379http://forums.asp.net/p/1765641/4817379.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi David, sjnaughton</p> <p>Thanks for your help.</p> <p>Ok, <strong>now</strong> I <strong>understand</strong> why I have to fix the namespace and in you MIX08 talk you did not.</p> <p>Could you please <strong>explain</strong> a bit more for <strong>completeness</strong> what&nbsp;the difference between having all the files in the same assembly WAP&nbsp;and not Web Site is?</p> <p>Does it mean that I can <strong>change individual aspx and code behind fies in Web sites&nbsp;and deploy them independently of the&nbsp;assembly</strong> but with WAP I have to always <strong>deploy the full assembly&nbsp;even if I change just one file</strong>? i.e. I have to compile the whole site even tough I change only one code behind file?</p> <p>As for the URL&nbsp;and 404 problem. I do not have the computer with me at the moment but will check it tomorrow and let you know.</p> <p><strong>One thing I have noticed yesterday is that for some reason VS 2010 created 2 folders MarsUsersAdmin when&nbsp;I created the application</strong></p> <p><strong>&nbsp;MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx</strong></p> <p>I have not changed the route at all. So I was wondering if this could be a problem for DD?</p> <p>Cheers</p> <p>C</p> 2012-02-05T21:34:10-05:004817436http://forums.asp.net/p/1765641/4817436.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>WAP vs Web Site can be a difficult choice, as they have pros and cons. In WAP's, the courses get compiled in VS at design time, while in Web Sites, everything is compiled at runtime (and there is no 'bin' assembly). Check out this <a href="http://vishaljoshi.blogspot.com/2009/08/web-application-project-vs-web-site.html"> post</a> which discusses many of the differences.</p> <p>For the 404, it's actually clear from the error message that you requested&nbsp;/DynamicData/CustomPages/tblUsers/List.aspx instead of going through the DD route, which is why you get this (those pages are not meant to be requested directly).</p> 2012-02-06T00:05:32-05:004818085http://forums.asp.net/p/1765641/4818085.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p></p> <blockquote><span class="icon-blockquote"></span> <h4>pallone</h4> MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx</blockquote> <p></p> <p>this path should be</p> <p>~/tblUsers/List.aspx</p> 2012-02-06T08:39:33-05:004818416http://forums.asp.net/p/1765641/4818416.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Hi David, sjnaughton,</p> <p>Thanks again.</p> <p>For some reason I run the application this mornning and the 404 error is gone.</p> <p>I do not understand what has happened but I think that setting the default.aspx as the starting page might have helped.</p> <p>I really appreciate your&nbsp;sharing you knwoledge with us</p> <p>Cheers</p> <p>C</p> <p>&nbsp;</p> 2012-02-06T11:00:05-05:004819042http://forums.asp.net/p/1765641/4819042.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>Most likely, what happened is that you were on that page and hit Ctrl-F5 to run it, which causes VS to launch the browser directly on that page instead of going through the proper routes. MVC views have the same issue. It's unfortunate that we couldn't quite get VS to do the right thing here, but oh well! :)</p> 2012-02-06T16:57:19-05:004819248http://forums.asp.net/p/1765641/4819248.aspx/1?Re+CustomPages+not+workingRe: CustomPages not working <p>thanks David</p> 2012-02-06T19:29:20-05:00