Last post Jun 30, 2017 10:12 AM by mgebhard
Jun 26, 2017 04:53 AM|sevi|LINK
Working with vs 2017, a very simple webform app with master page, which was created with the default.aspx page in the root of the project. The default.aspx page has had no changes, it links to various tutorial pages at microsoft.com.
I created a new folder called admin, and in it create another default.aspx. The app no longer complies; it gives this error:
Error BC30269 'Protected Sub Page_Load(sender As Object, e As EventArgs)' has multiple definitions with identical signatures
Why? The only postings I can find about this kind of error are usually from someone moving to a new machine or copy/pasting code and not adjusting the code for the new page name. I don't recall any limitation with asp.net where one cannot have two pages
with the same name, as long as they're in separate folders.
Jun 27, 2017 05:45 AM|Cathy Zou|LINK
I create a Default.aspx page in the root of my project page. Then I create a folder named “Admin”, in the folder.
I create a page with some name”Default.aspx”, when I run one of it.
However, There is no error. Everything woks ok.
If I copy the Default.aspx page in the root of my project page, Then paste it in Admin folder.
I encounter a error says that Type 'Default' already defines a member called 'Page_Load' with the same parameter types
The solution for above error is While coping the files in asp.net you should rename the file names as well as class names in aspx.cs file.
Jun 27, 2017 06:53 AM|sevi|LINK
I didn't copy any files. I even deleted the \admin\default.aspx file, and created it again from scratch. Same error.
Someone must have an idea how to fix this?
Jun 29, 2017 05:56 AM|zxj|LINK
Usually when you use Visual Studio to generate some code for you, it does them as Partial Class ... so you can create another partial class and add your own code to the same class without loosing your changes when the tool regenerates it's code.
Try to rename the Partial Class to the new page's classname.
Jun 29, 2017 04:06 PM|sevi|LINK
This is how I interpreted what you wrote: to rename the code behind class name, and change the inherits tag on the default.aspx page. It compiles now.
So one has to make this kind of change if one has two pages with the same name? Did this behavior change in recent versions of asp.net? Because there are numerous tutorials out there that use default.aspx in various folders and I don't recall any mention
of needing to adjust this.
Thanks for helping me sort it out.
Jun 29, 2017 07:30 PM|mgebhard|LINK
You should be able to create a new folder and create a default.aspx page within the folder. I've done this many time in VS 2017.
Next time you create a default page. Take a moment to look at the namespace and see if it conflicts with another default page. For example, if you create a default page in an admin folder the namespace would look similar to the following.
public partial class _default : System.Web.UI.Page
Jun 30, 2017 02:39 AM|sevi|LINK
So the namespace is not automatically managed by vs, so as to not create conflicts. Good enough...thanks for helping out.
Jun 30, 2017 10:12 AM|mgebhard|LINK
So the namespace is not automatically managed by vs, so as to not create conflicts.
No VS automatically creates the namespace. Whatever is happening is unique to your system.