Saturday, March 31, 2012

Separate code file

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

RegardsOn Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

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

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1171872789.521209.303890@.v45g2000cwv.googlegr oups.com...

Quote:

Originally Posted by

On Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

>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"
%>
>


On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

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

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1171897535.364021.46260@.l53g2000cwa.googlegro ups.com...

Quote:

Originally Posted by

On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

>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?
>


On Feb 19, 5:25 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

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.

0 comments:

Post a Comment