Creating VB.NET ASP.NET Application
Why does this happen:
1. I create a VB.NET project for an ASP.NET Application.
2. This is added to my webform1.aspx page:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Test2.WebForm1"%>
3. I load webform1.aspx in the browser and eveything works okay.
4. I rename webform1.aspx to test2.aspx
5. I load test2.aspx in the browser and eveything works okay.
6. I don't like the class name of WebForm1 in my test2.apsx.vb file, so I rename it to Test2:
Public Class WebForm1 is edited to:
Public Class Test2
7. I load test2.aspx in the browser and now I get 'Could not load type 'Test2.Test2'' error. So I think that the test2.apsx.vb file needs a namespace specifier, so I add a namespace specifier around the Test2 class definition the in test2.apsx.vb file:
8. I load it in the browser and get the same error.
9. I add src="test2.aspx.vb" to the <% %> line in my test2.aspx file.
10. I load it in the browser and everything works okay.
Q: Why did I need to add the namespace and src modifiers when I changed the name of the class in the codebehind file? Why aren't they just included when the project is created, so that I wouldn't need to add the namespace and src modifiers, I would just need to change all found instances of WebForm1 to <NewClassName>.
Q: Is there a place where I can specify what the new class name is when I create the project? What if I want a new class name other than WebForm1?
Friday, September 20, 2002
In your first problem, when you change the .vb class name to test2, are you also changing the inherits= value? If so, and you recompile, it should work.
For Q2, when you click "Add new web form", just change the name from WebForm1.aspx to Myform.aspx" and it'll create it with that class name. No need to rename :)
Saturday, September 21, 2002
On your second point, that works if you are adding a web form to an existing project, but there is no way to change the name of the web form when you initially create the project.
Sunday, September 22, 2002
Oh right, well renaming should work if the inherits is set correctly.
At any rate I just delete the auto-created form.
Monday, September 23, 2002
Good Idea to just delete the default form. Shouldn't have to jump through that loop, though....
Tuesday, September 24, 2002
Fog Creek Home