2 programming languages in one piece of code

Z

zee

Hi all
I am a newbie where programming with c# is concerned. One thing that
seems to come up often when reading about it and .Net is that you can
use different languages on a piece of code. Is that possible and how do
you do it. I have written a simple application which has a page that has
buttons (navigate with them). I also have a clock in the corner, but I
would love to use <%@ Page Language ="VB" %> together with c#. This
means that the language used in buttons is c# but the language used in
the clock is VB. all of this in one page, one piece of code, is it
possible?

Thanks in advance
Zee
 
T

Trebek

Zee,

The best way to accomplish this is either create the control/assembly/class
in a separate C# project and then add this project to your VB page solution
or to write the assembly in c# and then use the Page directive 'Assembly'
(and Imports namespace -- if different namespace) to handle the importing of
this class into your page. If you are using codebehind, the first option is
preferred. If not, the second will work as well. If you intend to take
action in the button press that will affect the aspx page, you will need to
grab the current HttpContext thru the use of HttpContext.Current.

HTH,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top