Click here to Skip to main content
11,408,835 members (65,180 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 9:15am
AspDotNetDev192.1K
Edited 27-Oct-11 8:23am
v2
Comments
SAKryukov at 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 at 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 at 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 at 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 at 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.

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

  Print Answers RSS
0 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 320
2 Maciej Los 155
3 Peter Leow 140
4 Dave Kreskowiak 115
0 Sergey Alexandrovich Kryukov 8,676
1 OriginalGriff 6,855
2 Maciej Los 3,322
3 Abhinav S 3,238
4 Peter Leow 3,034


Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 27 Oct 2011
Copyright © CodeProject, 1999-2015
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