Re: aspx.vb webform redirect to aspx.cs webform in another project within the same solution...and back again?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Hazzard (hazz_at_sonic.net)
Date: 03/11/04


Date: Thu, 11 Mar 2004 10:55:08 -0800

And thank you for the idea of using codebehind and referencing a dll which I
could create with the C# code. That is another option.
You gave me some ideas and I can decide which makes the most sense. For less
than a dozen or so methods, translate. For more, create the dll and
reference it. How does that sound for a rule of thumb?
-greg

"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:F1iBmUmBEHA.604@cpmsftngxa06.phx.gbl...
> Hi Greg,
>
> Thanks for posting in the community!
> Based on my understanding, you've a certain ASP.NET web page designed via
> C#(using codebehind page class). Now, you are dealing with a VB.NET web
> project and want to resue the C# based page. Since we can't use
> multi-lanugage in a single project, you'd like to create a separate C#
> webproject to hold the C# web page and let the page in different web
> project navgiator to each other, yes?
> If there is anything I misunderstood, please feel free to let me know.
>
> As for this problem, here are my suggestions:
> 1. Every ASP.NET web project is actually a separate web application from
> each other which has its own resources and intrinsic objects such as
> AppliationState, SessionState.. They're very important things for a web
> app. So If you put the C# page in a different web project, there'll cause
> some problems if you'd like to share session or application state data
> between them.
>
> 2. If you just want to reuse the page in the VB.NET project, here are two
> means to still use it:
> 1) There are some web links where provide the service to translate the C#
> code to vb.net or the contrary, if you only have not much pages to convert
> or the code is not so complex, it is ok to translate them into vb.net.
Here
> is a web link to a convert service:
> #C# to VB.NET Translator
> http://authors.aspalliance.com/aldotnet/examples/translate.aspx
>
> 2) Since the ASP.NET web page is actually inherits from the codebehind
page
> class(if you use codebehind). You may find the "inherits=..." in the aspx
> file's @page directive as below:
> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Index.aspx.vb"
> Inherits="Codebehindclass's full name"%>
>
> In fact, we can sepcify a page derived from an existing class avaliable in
> the project(as long as we have referenced the class's assembly in our
> project). Thus, we can create a C# class library project and compiled the
> c# codebehind page class into a single assembly(dll) and then reference
the
> assembly in the VB.NET project. For example, we define the C# page class
> named "MyCsPages.LoginPage", then we can specify a page in the VB.NET web
> app to use the c# page class as below:
> <%@ Page Language="vb" AutoEventWireup="false"
> Inherits="MyCsPages.LoginPage"%>
>
> Notice that no code-behind needed because we use a page class in a
external
> assembly as the page's parent class.
> How do you think of this means? And here is a tech article in MSDN on
> ASP.NET web page code model:
>
> #Web Forms Code Model
>
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconWebFormsCodeModel.as
> p?frame=true
>
> Please check out the above suggestions. If you feel anything unclear,
> please feel free to post here.
>
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>


Quantcast