Converting ASPX pages from VB.NET to C#

G

glenn.e.martin

Are there any significant stopping blocks from taking an ASPX Page
someone designs in VB.NET, and redoing the Code behind page to use C#?

Is the Code behind the only thing one would need to change? ...That
and the Page Language="vb" in the HTML? (Are there differences to the
way each lays out the HTML?)

I wouldn't mind some utilities, but would also like to know what's
involved in doing it manually.
 
N

Nick

Hi Glen

I'm a newcomer to asp and .net but I understand that the code behind
principle was designed for that very reason so that the HTML and the code
are seprate so you are free to write the code in any .net supported
language. So as far as I know (in my limited experience) you would only need
to change the code behind file.

Nick
 
M

Mona

Hi Glenn,

Sometimes transforming VBNET code C# in code behind can lead to
unexpected results.The reason for this is that VB.NET protects the developer
from literal
strings by automagically parsing it and changing things like line feeds,
tabs, double-quotes, etc to their respective ASCII codes and then stores
them that way (AFAIK).

C# does not do this. (In C based languages, things like double quotes have
to
be escaped, much as you have seen in your code
output: --><meta name=\"generator\" content=\"microsoft visual studio
...net\"><--)

For instance, when you create a string using the line:
"The "quick" brown dog
jumped over the lazy fox."

VB.NET will parse it and convert all the \r\n (typical windows linefeed) and
double quotes for you. C# on the other hand will parse it as "The \"quick\"
brown dog\r\njumped over the lazy fox". This is because C# reads the string
literally.

HTH

Mona[Grapecity]
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top