Copy/duplicate web forms?

?

:-)

What is the easiest way to make a copy of a WebForm with a different
name? If you just copy/paste, the class info gets mangled. If you
create a new WebForm and copy everything over, it is exceedingly
tedious and manual for a large site. There has to be an easy way I'm
missing....
 
E

Edward

In Visual Studio IDE, do a file->save as... you need to
change a portion of the page directive of the newly
created file. In the inherits attribute of the page
directive, change the class to something different like
the name of your newly created file. Go to the code behind
page and change the name of the class to match what you
have in the page directive.
If you're using visual studio IDE, make sure that you
click on show all files and include back your previous file

Hope this helps!
 
?

:-)

Thanks, Edward. That's pretty much the way I'm doing it now (and it
sucks!). Seems like there ought to be a "clone" feature that replaces
all the necessary references for you (i.e. objects/inheritance in VS
itself...).

Sure wish there was also better interoperability between VS and
FrontPage since these are no brainers with FP. All the helpful
"WebBots" are useless when using the ASP.NET/ASPX pre-processor. Dang
it!
 
G

George Durzi

Check this out. I have a file called _template.aspx that I use for all my
applications.

On the aspx side, here's the Page directive:
<%@ Page language="c#" Codebehind="_template.aspx.cs"
AutoEventWireup="false" Inherits="MyNamespace.__template" %>

On the C# side:
namespace MyNamespace
{
public class __template : System.Web.UI.Page
{

So here's what I do. I select _template.aspx in my Solution Explorer, do
Ctrl-C, then Ctrl-V. Now I have a webform called Copy of _template.aspx.

I rename it to SomeWebForm.aspx. Now my Page Directive is:
<%@ Page language="c#" Codebehind="SomeWebForm.aspx.cs"
AutoEventWireup="false" Inherits="MyNamespace.__template" %>

And I go into my codebehind, and change the class definition from:

On the C# side:
namespace MyNamespace
{
public class __template : System.Web.UI.Page
{

to

On the C# side:
namespace MyNamespace
{
public class SomeWebForm : System.Web.UI.Page
{

what happens is that the IDE automatically changes my Page Directive to:
<%@ Page language="c#" Codebehind="SomeWebForm.aspx.cs"
AutoEventWireup="false" Inherits="MyNamespace.SomeWebForm" %>


This might seem a little clumsy, but it takes me two seconds to do...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top