Web Form acts differently when using C# than VB

Discussion in 'ASP .Net' started by Joe Fallon, Feb 15, 2004.

  1. Joe Fallon

    Joe Fallon Guest

    I have a sample web form in C# that works correctly.
    When I translated it to VB I can't get one feature in it working.
    ==============================================
    The part that does not work in VB is:
    <%= Context.Items["SomeKey"] %>
    and:
    <%= this.SomeProperty %>

    ==============================================
    Part of the C# HTML code looks like this:
    <HTML>
    <HEAD>
    <title>
    <%= Context.Items["SomeKey"] %>
    </title>
    <%= this.SomeProperty %>
    </HEAD>

    ==============================================
    Part of the VB HTML code looks like this:
    <HTML>
    <HEAD id="Head" runat="server">
    <title>
    <%= Context.Items("SomeKey") %>
    </title>
    <%= Me.SomeProperty %>
    </HEAD>

    ==============================================

    When I remove the <% %> type of code from the HTML my page runs correctly.
    But I get a blank page when I leave it in.

    Any ideas?

    --
    Joe Fallon
     
    Joe Fallon, Feb 15, 2004
    #1
    1. Advertising

  2. Joe Fallon

    Peter Blum Guest

    I don't think the language itself is the problem. I also don't see an error
    with your code. However, two things come to mind:
    1. In your translation, you didn't correctly assign "SomeKey" to
    Context.Items. I always recommend using this form of adding to a collection:
    Context.Items.Add("name", value)
    over
    Context.Items("name") = value

    2. The value of "SomeKey" is not a string. It must be converted to a string.
    Use "Context.Items("SomeKey").ToString()"

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Joe Fallon" <> wrote in message
    news:%...
    > I have a sample web form in C# that works correctly.
    > When I translated it to VB I can't get one feature in it working.
    > ==============================================
    > The part that does not work in VB is:
    > <%= Context.Items["SomeKey"] %>
    > and:
    > <%= this.SomeProperty %>
    >
    > ==============================================
    > Part of the C# HTML code looks like this:
    > <HTML>
    > <HEAD>
    > <title>
    > <%= Context.Items["SomeKey"] %>
    > </title>
    > <%= this.SomeProperty %>
    > </HEAD>
    >
    > ==============================================
    > Part of the VB HTML code looks like this:
    > <HTML>
    > <HEAD id="Head" runat="server">
    > <title>
    > <%= Context.Items("SomeKey") %>
    > </title>
    > <%= Me.SomeProperty %>
    > </HEAD>
    >
    > ==============================================
    >
    > When I remove the <% %> type of code from the HTML my page runs correctly.
    > But I get a blank page when I leave it in.
    >
    > Any ideas?
    >
    > --
    > Joe Fallon
    >
    >
    >
    >
     
    Peter Blum, Feb 15, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Web control that acts as a xml data island

    Mark Goldin, Apr 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    392
    Ken Cox [Microsoft MVP]
    Apr 29, 2004
  2. Jim
    Replies:
    2
    Views:
    471
  3. John Kotuby
    Replies:
    3
    Views:
    2,628
    John Kotuby
    Feb 15, 2008
  4. gargoyle
    Replies:
    3
    Views:
    140
    Ilya Zakharevich
    Feb 17, 2005
  5. Yahav
    Replies:
    10
    Views:
    239
    Tad McClellan
    Mar 23, 2005
Loading...

Share This Page