Results 1 to 3 of 3

Thread: Copying a p[age in VS.net

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Copying a p[age in VS.net

    I have a page in my web project "Webform.aspx" which has the general layout of all my pages and a blank code behind page
    .
    What I do is :

    1) Copy the page and paste it into Visual Studio.
    2) Rename it to......lets say "Webform1.aspx"
    3) Change the code behing page so it reads
    Public Class WebForm1

    Whenever I try to run this new blank page I get the error :

    Could not load type '_myProject.WebForm1'.

    Can someone tell me how to do this. I am finding Visual Studio great for coding but at simple screen handling and general maintenance It is hopeless.

    Thanks in Advance

    Parksie

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    In the top of the HTML side of your page, you'll have:
    Code:
    <%@ Page language="c#" Codebehind="pagename.aspx.cs" AutoEventWireup="false" Inherits="Namespace.pagename" %>
    You have to make sure that the namespace & pagename parts match that of your new file's. So, if your original file came from:
    Code:
    <%@ Page language="c#" Codebehind="Webform.aspx.cs" AutoEventWireup="false" Inherits="MyProject.WebForm" %>
    and you copy it to MyProject/Subfolder
    Code:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="MyProject.Subfolder.WebForm1" %>
    If I'm not mistaken

    [Edit]
    And make sure that the namespace in your code behind file matches that of the HTML.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Dude, you are doing way to much work. If you got a page template that other pages will be using, you should be using inheritance. Check out this link, it will help you out greatly.
    http://www.codeproject.com/aspnet/page_templates.asp

    Plus, if each page inherits from the base page, you can change just the base page, and all others get the changes automatically. It is awesome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width