This is probably very simple but I am at a loss as to what's causing this as most of the post on here are in C#.
I'm using VB.NET and the recent preview version.
Custom Class In app_code:
'Trying out the renderHint etc.
[MetadataType(typeof(ContactMetadata))]
'This shows the blue line under MetadataType ......... How do i fix it, am i missing a ref PartialPublicClass Contact EndClass
PublicClass ContactMetadata
[RenderHint("CategoryName",
"Text")] ' Again the blue squiggle under RenderHint
[Description("CategoryName",
"TEST")] ' Again the blue squiggle under Description EndClass
Appologies if this is so simple by I can't figure it out in vb.
Are you using the recent
preview, or the older build from December? In the recent preview, RenderHint is now called UIHint. Also, you need to import System.ComponentModel in order to use the Description attribute.
I'm still a bit confused with this, it is trying to convert the C# to VB thats killing me and since all the examples i can find are in C# I need a bit more help.
I changed [] to <> and i've now got this.
<MetadataType(
Typeof(ContactMetadata)> ' problem here it's looking for an Is like ContactMetadata) IS > ' is what ?
Partial Public
Class Contact
End
Class
If one of you guys would be so kind as to convert this tiny bit of C# to VB for me I should be able to figure the rest out by my self.
[MetadataType(typeOF(Product_MD))]
public partial class Product {
partial void OnProductNameChanging(string value) {
if (value[0] == 'a')
throw exception("Must not start with a");
}
}
public class Product_MD {
[DisplayName("My Units)]
[Description("This is whats left")]
Public object UnitsInStock { get; set; }
'typeof' in C# is 'GetType' in VB. Though I'm a bit curious: why are you choosing to use VB for this if you are not already familiar with the language? The issue you are running into are pure VB syntactic issues, and are not directly related to Dynamic
Data.
Thanks for 'Though I'm a bit curious: why are you choosing to use VB for this if you are not already familiar with the language?' is suppose it's a more polite way of telling me to RTFM.
Anyway I am, as you put it familiar with the language but I am no expert, what I have no clue about is C# and since all the examples i can find are in C# this is my problem,
how would i know "typeof" maps to "GetType" in vb when i don't know C# from my elbow.
I though the whole point of community forums were share knowlage and help other members, beginers and experienced users alike.
I am not all that experienced in ASP.NET but i have been able with my limited knowlage to put together the login and membership areas of
my site due to onlne articles and the odd post on forums to get me started.
As for my post not being related to Dynamic Data i beg to differ.
The post relates to the CustomClasses used in dynamic data. After all I only asked for a conversion of 12 lines of code that would have got my up and running but you choose to give me the old RTFM
answer i apreciate that.
Oh the code i was looking to get converted, was it not from YOUR WEB CAST titled Developing Data Driven Applications Using ASP.NET Dynamic Data Controls, and your telling me my post is not related to dynamic data.
Apologies, I didn't mean it that way. I was just trying to separate the issues into different 'buckets'. i.e. the fact that in C# attributes use [ ] while in VB it is < > is in itself a pure C# vs VB syntactic issue, and not directly related to Dynamic
Data. But clearly, you are trying to use Dynamic Data, and in that sense you're in the right place!
To learn how C# converts to VB, there are some online translators that can take you part of the way there. e.g. try
this one. However, note that it is targetting the languages as of their 2.0 version, which don't include some of the newer features (.e.g. no Linq support). Still, I think for your particular
code snippet, it should get you some VB code in pretty decent shape.
Could you try this and let us know if there are still issues? Dont' worry, we'll get you running! :)
David
Marked as answer by davidebb on Apr 14, 2008 05:37 PM
No offence taken, that converter was what I've been needing, it seems the one I've been using is not very good and was throwing conversion errors when i put that
code chunk through. The one you gave me has given me what I need I should be able to figure out the rest from here.
Just to let you know, the code samples that we will provide for the Dynamic Data documentation show both C# and VB languages.
The last release of the docs was the December CTP (http://quickstarts.asp.net/3-5-extensions/dyndata/default.aspx) and we are now working to create the samples for the new bits.
Regards,
Maíra
This posting is provided "AS IS" with no warranties, and confers no rights.
An even better converter is available at
www.codechanger.com. It was able to successfully convert all the examples into VB for me when I started playing with this as well.
JBravo69
0 Points
7 Posts
Problem with custome Class VB.NET
Apr 14, 2008 02:53 PM|LINK
Hi Guys,
This is probably very simple but I am at a loss as to what's causing this as most of the post on here are in C#.
I'm using VB.NET and the recent preview version.
Custom Class In app_code:
'Trying out the renderHint etc.
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.ComponentModel.DataAnnotations
Imports System.Web.DynamicData
[MetadataType(typeof(ContactMetadata))] 'This shows the blue line under MetadataType ......... How do i fix it, am i missing a ref
Partial Public Class Contact
End Class
Public Class ContactMetadata
[RenderHint("CategoryName", "Text")] ' Again the blue squiggle under RenderHint
[Description("CategoryName", "TEST")] ' Again the blue squiggle under Description
End Class
Appologies if this is so simple by I can't figure it out in vb.
Regards
Bravo
adman666
Member
468 Points
71 Posts
Re: Problem with custome Class VB.NET
Apr 14, 2008 02:58 PM|LINK
Hi,
In VB the square brackets [] should be angle brackets <> when you are decorating methods.
Hope this helps.
Thanks.
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: Problem with custome Class VB.NET
Apr 14, 2008 02:58 PM|LINK
Are you using the recent preview, or the older build from December? In the recent preview, RenderHint is now called UIHint. Also, you need to import System.ComponentModel in order to use the Description attribute.
thanks,
David
JBravo69
0 Points
7 Posts
Re: Problem with custome Class VB.NET
Apr 14, 2008 03:40 PM|LINK
Thanks so far guys much apreciated,
Ok I got the <> part and the missing reference.
I'm still a bit confused with this, it is trying to convert the C# to VB thats killing me and since all the examples i can find are in C# I need a bit more help.
I changed [] to <> and i've now got this.
<MetadataType(
Typeof(ContactMetadata)> ' problem here it's looking for an Is like ContactMetadata) IS > ' is what ?Partial Public Class Contact
End
ClassIf one of you guys would be so kind as to convert this tiny bit of C# to VB for me I should be able to figure the rest out by my self.
[MetadataType(typeOF(Product_MD))]
public partial class Product {
partial void OnProductNameChanging(string value) {
if (value[0] == 'a')
throw exception("Must not start with a");
}
}
public class Product_MD {
[DisplayName("My Units)]
[Description("This is whats left")]
Public object UnitsInStock { get; set; }
}
Thanks in advance.
Bravo.
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: Problem with custome Class VB.NET
Apr 14, 2008 03:53 PM|LINK
'typeof' in C# is 'GetType' in VB. Though I'm a bit curious: why are you choosing to use VB for this if you are not already familiar with the language? The issue you are running into are pure VB syntactic issues, and are not directly related to Dynamic Data.
thanks,
David
JBravo69
0 Points
7 Posts
Re: Problem with custome Class VB.NET
Apr 14, 2008 04:34 PM|LINK
Hi David,
Thanks for 'Though I'm a bit curious: why are you choosing to use VB for this if you are not already familiar with the language?' is suppose it's a more polite way of telling me to RTFM.
Anyway I am, as you put it familiar with the language but I am no expert, what I have no clue about is C# and since all the examples i can find are in C# this is my problem,
how would i know "typeof" maps to "GetType" in vb when i don't know C# from my elbow.
I though the whole point of community forums were share knowlage and help other members, beginers and experienced users alike.
I am not all that experienced in ASP.NET but i have been able with my limited knowlage to put together the login and membership areas of
my site due to onlne articles and the odd post on forums to get me started.
As for my post not being related to Dynamic Data i beg to differ.
The post relates to the CustomClasses used in dynamic data. After all I only asked for a conversion of 12 lines of code that would have got my up and running but you choose to give me the old RTFM
answer i apreciate that.
Oh the code i was looking to get converted, was it not from YOUR WEB CAST titled Developing Data Driven Applications Using ASP.NET Dynamic Data Controls, and your telling me my post is not related to dynamic data.
Thanks
Bravo
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: Problem with custome Class VB.NET
Apr 14, 2008 04:57 PM|LINK
Apologies, I didn't mean it that way. I was just trying to separate the issues into different 'buckets'. i.e. the fact that in C# attributes use [ ] while in VB it is < > is in itself a pure C# vs VB syntactic issue, and not directly related to Dynamic Data. But clearly, you are trying to use Dynamic Data, and in that sense you're in the right place!
To learn how C# converts to VB, there are some online translators that can take you part of the way there. e.g. try this one. However, note that it is targetting the languages as of their 2.0 version, which don't include some of the newer features (.e.g. no Linq support). Still, I think for your particular code snippet, it should get you some VB code in pretty decent shape.
Could you try this and let us know if there are still issues? Dont' worry, we'll get you running! :)
David
JBravo69
0 Points
7 Posts
Re: Problem with custome Class VB.NET
Apr 14, 2008 05:19 PM|LINK
Hi David,
No offence taken, that converter was what I've been needing, it seems the one I've been using is not very good and was throwing conversion errors when i put that
code chunk through. The one you gave me has given me what I need I should be able to figure out the rest from here.
Thanks
Bravo.
maira.wenzel
Member
511 Points
111 Posts
Microsoft
Re: Problem with custome Class VB.NET
Apr 14, 2008 06:47 PM|LINK
Bravo,
Just to let you know, the code samples that we will provide for the Dynamic Data documentation show both C# and VB languages.
The last release of the docs was the December CTP (http://quickstarts.asp.net/3-5-extensions/dyndata/default.aspx) and we are now working to create the samples for the new bits.
Regards,
Maíra
peetie12
Member
18 Points
11 Posts
Re: Problem with custome Class VB.NET
Apr 18, 2008 03:22 AM|LINK
An even better converter is available at www.codechanger.com. It was able to successfully convert all the examples into VB for me when I started playing with this as well.