Converting ASPX pages from VB.NET to C#

Discussion in 'ASP .Net' started by glenn.e.martin, Apr 29, 2005.

  1. 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.
     
    glenn.e.martin, Apr 29, 2005
    #1
    1. Advertisements

  2. glenn.e.martin

    Nick Guest

    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
     
    Nick, Apr 29, 2005
    #2
    1. Advertisements

  3. glenn.e.martin

    Mona Guest

    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]
     
    Mona, Apr 29, 2005
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.