Web Form acts differently when using C# than VB

  • Thread starter Thread starter Joe Fallon
  • Start date Start date
J

Joe Fallon

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?
 
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: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top