locked
Creating custom pages based on existing page templates RRS feed

  • Question

  • User2088568668 posted

    I tried creating a different Lists.aspx for one of my tables. However when I copy the existing Lists.aspx from the page templates folder to the a custom folder, I'm getting an an error specifying my controls are ambiguous. I figured this because the controls are already existing on the same namespace. How do I get around it? How come when Scott did a demo about it he didnt get an error?

    Thursday, October 30, 2008 10:21 AM

Answers

  • User1641955678 posted

    Whether it works directly or not depends on whether you're using a Web Site or a Web Application.  In a Web App, just copying the page indeed doesn't work because of the duplication.  To fix the issue, simply change the namespace to match the folder where you're putting the file.  Note that you need to change this both in the .cs file and in the .aspx.cs file.

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 30, 2008 10:49 AM
  • User-1005219520 posted

    For example, if you create a dynamic data project (LINQ to SQL, not a Dynamic data Entities project) and call the project L2ScustPage - it will decorate the .cs (or vb) code with namespace L2ScustPage { 

    When you copy List.aspx to the DynamicData\CustomPages\Products\List.aspx directory (I'm scaffolding the Product table from AWLT) - you get compiler errors from the duplicate definitions.  In the DynamicData\CustomPages\Products\List.aspx.cs and the DynamicData\CustomPages\Products\List.aspx.designer.cs files change the namespace. Here is how I did it:

    //namespace L2ScustPage {

    namespace L2ScustPage.Products {

    I'll open a bug on How to: Customize the Layout of an Individual Table By Using a Custom Page Template as it doesn't mention this problem.<!---->

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 30, 2008 10:11 PM
  • User-330204900 posted

    Also in the ascx page:

    <%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="L2ScustPage.Products.List" %>

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 31, 2008 3:49 AM

All replies

  • User1641955678 posted

    Whether it works directly or not depends on whether you're using a Web Site or a Web Application.  In a Web App, just copying the page indeed doesn't work because of the duplication.  To fix the issue, simply change the namespace to match the folder where you're putting the file.  Note that you need to change this both in the .cs file and in the .aspx.cs file.

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 30, 2008 10:49 AM
  • User-1005219520 posted

    If you don't have a compelling reason to use Web App, consider using a Web site. This and many other problems disappear.

    Thursday, October 30, 2008 1:23 PM
  • User-1005219520 posted

    For example, if you create a dynamic data project (LINQ to SQL, not a Dynamic data Entities project) and call the project L2ScustPage - it will decorate the .cs (or vb) code with namespace L2ScustPage { 

    When you copy List.aspx to the DynamicData\CustomPages\Products\List.aspx directory (I'm scaffolding the Product table from AWLT) - you get compiler errors from the duplicate definitions.  In the DynamicData\CustomPages\Products\List.aspx.cs and the DynamicData\CustomPages\Products\List.aspx.designer.cs files change the namespace. Here is how I did it:

    //namespace L2ScustPage {

    namespace L2ScustPage.Products {

    I'll open a bug on How to: Customize the Layout of an Individual Table By Using a Custom Page Template as it doesn't mention this problem.<!---->

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 30, 2008 10:11 PM
  • User-330204900 posted

    Also in the ascx page:

    <%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="L2ScustPage.Products.List" %>

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 31, 2008 3:49 AM
  • User-1005219520 posted

    Thanks Steve,

     Yes, that one is easy to miss.

    Friday, October 31, 2008 1:23 PM
  • User838776874 posted

    Hello,  ...Utilizing Visual Studio 2010, I have built an "ASP.NET Dynamic Data Entities Web Application" utilizing "ADO.NET Entity Data Model".   I am using SQL Server 2008, instead of SQL Express.  I have attempted to follow Scott Hanselman's video to reorder my column headers for a particular table and am not having a successful experience.  However on the good side, I am not receiving any errors.

    • From the CustomPages folder, I created a folder for my table (tblDevices)
    • I copied ListDetails.aspx from the PageTemplates folder and placed in the newly created tblDevices folder
    • I made the following changes from CustomPages\tblDevices\ListDetails.aspx
      • Change
        • From:      Inherits=”InventoryManager.ListDetails”
        • To:           Inherits=”InventoryManager.Custom_ListDetails”
    • I add the following lines of code:
      • AutoGenerateColumns="false"
      • AutoGenerateRows="false"
      • <Columns>
        • <asp:DynamicField DataField="device_tag_no" />
        • <asp:DynamicField DataTable="tblCategory" />
        • <asp:DynamicField DataField="device_tag_no" />
        • <asp:DynamicField DataField="device_serial_no" />
        • <asp:DynamicField DataField="device_part_no" />
        • <asp:DynamicField DataField="cpu" />
        • <asp:DynamicField DataField="RAM" />
        • <asp:DynamicField DataField="HD" />
        • <asp:DynamicField DataField="device_comment" />                             
        • <asp:DynamicField DataField="purchase_date" />
        • <asp:DynamicField DataField="replacement_date" />
        • <asp:DynamicField DataTable="tblLease" />
        • <asp:DynamicField DataTable="tblLocation" />
        • <asp:DynamicField DataTable="tblRoom" />
        • <asp:DynamicField DataTable="tblDepartment" />
        • <asp:DynamicField DataTable="tblDivision" />
        • <asp:DynamicField DataTable="tblEmployee" />
        • <asp:DynamicField DataTable="tblAssignment" />
      • </Columns>
    • I made the following changes from CustomPages\tblDevices\ListDetails.aspx\ListDetails.aspx.cs
      • Change:
        • From:  public partial class ListDetails : System.Web.UI.Page
        • To:      public partial class Custom_ListDetails : System.Web.UI.Page
    • I am not receiving any errors, but the order of my column headers have not changed either.
    • any suggestions would be greatly appreciated.
    Monday, September 19, 2011 12:07 PM
  • User-330204900 posted

    It sounds to me like it is still using autogeneration of columns

    Monday, September 19, 2011 1:22 PM
  • User838776874 posted

    Any suggestions, please sir?

    Monday, September 19, 2011 1:24 PM
  • User-330204900 posted

    You would need to post thePage_Init and Page_Load from code behind

    Wednesday, September 21, 2011 6:12 AM