Web Form acts differently when using C# than VB

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?
 
P

Peter Blum

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
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top