Click here to Skip to main content
12,451,243 members (51,876 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB ASP.NET VB.NET
I can't seem to import a generic type on an ASP.Net page set to a language of "vb":

<%@ Page Language="vb" %>
<%-- This works fine. --%>
<%@ Import Namespace="MyString=System.String" %>
<%-- This gives an error. --%>
<%@ Import Namespace="MyList=System.Collections.Generic.List(Of System.String)" %>
<%-- Error: "The 'namespace' attribute cannot contain spaces." --%>

Note that I'm NOT interested in these alternatives (for boring reasons you don't care about):
  • Alter the web.config.
  • Alter the code-behind.
  • Use the code-behind instead of the page.
  • Using C# instead of VB.Net.
  • Googling (the MSDN page makes no mention of generic types).
  • Modifying the app.config.
  • Adding the namespace to the "imported namespaces" via the "References" tab in the project settings.
  • Workarounds (I already have workarounds, but I want to see if this can be done properly).

Is it possible to alias a generic type on a VB.Net ASP.Net page, or is this an oversight by Microsoft?
Posted 26-Oct-11 8:15am
AspDotNetDev193.1K
Updated 27-Oct-11 7:23am
v2
Comments
SAKryukov 26-Oct-11 14:43pm
   
Hm, interesting question, I voted 5.
I never tried such thing with ASP.NET (that's why I'm not posting any solution), but at first glance actually would expect that if "MyString=System.String" works, "MyList=System.Collections.Generic.List(Of System.String)" should work.

Actually I would certainly recommend to avoid it by resorting to one of the alternatives you deny by "boring reasons", like the last one, but it would not make the formulation of the problem invalid.
--SA
JRickey 28-Oct-11 2:00am
   
I came across one allusion to using (System.String()) instead of (Of System.String) as a way to circumvent the no-space restriction.
AspDotNetDev 28-Oct-11 2:05am
   
Doesn't seem to work. I came across some funky syntax that used an apostrope and some square brackets, but I forget exactly what it looked like. I'll probably do some more searching tomorrow.
AspDotNetDev 28-Oct-11 2:08am
   
Actually, I just tried the syntax I was thinking of and it didn't work: MyList=System.Collections.Generic.List`1[System.String]
JRickey 28-Oct-11 13:10pm
   
Have you tried substitutes for the space (such as %20, etc.)? Another possibility is something akin to white-space handling.
himanshu agarwal 30-Jul-15 5:10am
   
I believe you are not importing a namespace there when you say System.Collections.Generic.List(Of System.String), you should just try aliasing to import System.Collections.Generic or System.Collections.Generic.List
AspDotNetDev 1-Aug-15 22:32pm
   
That is exactly my problem, as I indicated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 27 Oct 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100