Separate code file

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a button on a webform. When I double click the button to create click
event it is created in the same file (aspx). How can I tell vs2005 to create
the code in a separate aspx.vb file?

Thanks

Regards
 
Hi

I have a button on a webform. When I double click the button to create click
event it is created in the same file (aspx). How can I tell vs2005 to create
the code in a separate aspx.vb file?

Thanks

Regards

You enable the ASP .NET code-behind feature by adding attributes to
the @Page directive.

for VB

<%@ Page Language="VB" Inherits="myClass" CodeBehind="myPage.aspx.vb"
%>

for C#

<%@ Page Language="C#" Inherits="myClass" CodeBehind="myPage.aspx.cs"
%>
 
Does that mean that it is not something one should normally be doing
otherwise it would have been provided by default?

Thanks

Regards
 
Does that mean that it is not something one should normally be doing
otherwise it would have been provided by default?

VS creates that by default, when you add a new WebForm into project.
How do you created it?
 
Hi

I suspect I copied from another predone webform. I have now added this line
at the top;

<%@ Page Language="VB" MasterPageFile="MyMaster.master"
AutoEventWireup="false" CodeFile="MyPage.aspx.vb"
Inherits="Events_Settings_MyPage" Title="My Title" %>

and it says 'file '/Events/Settings/MyPage.aspx.vb' does not exist.' which
of course is true as the page did not have code behind to start with. How
can I now get vs to create the MyPage.aspx.vb file and link to the webform?

Thanks

Regards
 
Hi

I suspect I copied from another predone webform. I have now added this line
at the top;

Well, I think the best way is to add a new webform to your project. VS
will create aspx and the one for code-behind. Then you can copy your
code to this new webform, or use created code-behind *.vb as an
example.
 
Back
Top