I'm fairly new to VB.net and ASP.net and most of the tutorials for webpages is done in C#.net. I've been successful in converting the c# to vb until now and I am stumped.
I'm trying to convert the following code in a helper file without success.
Helper file:
<!DOCTYPE html>
<head>
<title>Test Helpers Page</title>
</head>
<body>
<p>This is some opening paragraph text.</p>
<!-- Insert the call to your note helper here. -->
@MyHelpers.MakeNote("My test note content.")
<p>This is some following text.</p>
</body>
</html>
It should show a box with Note and the text that is in parenthesis in
@MyHelpers.MakeNote("My test note content.")
I should be able to change the text in parenthesis
but the only way I can get it to work is by adding
dim content = "My test note content" in the helper file.
and delete it in the parenthesis.
My helper file looks like this
@helper MakeNote()
dim content = "My test note content"
timb1021
Member
3 Points
9 Posts
Converting C#.net to VB.net
May 15, 2012 05:03 PM|LINK
I'm fairly new to VB.net and ASP.net and most of the tutorials for webpages is done in C#.net. I've been successful in converting the c# to vb until now and I am stumped.
I'm trying to convert the following code in a helper file without success.
Helper file:
@helper MakeNote(string content) {
<div class="note" style="border: 1px solid black; width: 90%; padding: 5px; margin-left: 15px;">
<p>
<strong>Note</strong> @content
</p>
</div>
}
It is used in the following page code.
<!DOCTYPE html>
<head>
<title>Test Helpers Page</title>
</head>
<body>
<p>This is some opening paragraph text.</p>
<!-- Insert the call to your note helper here. -->
@MyHelpers.MakeNote("My test note content.")
<p>This is some following text.</p>
</body>
</html>
It should show a box with Note and the text that is in parenthesis in
@MyHelpers.MakeNote("My test note content.")
I should be able to change the text in parenthesis
but the only way I can get it to work is by adding
dim content = "My test note content" in the helper file.
and delete it in the parenthesis.
My helper file looks like this
@helper MakeNote()
dim content = "My test note content"
@<div class="note" style="border: 1px solid black; width: 90%; padding: 5px; margin-left: 15px;">
<p><strong>Note</strong>   @content</p>
</div>
End Helper
It works but it defeats the purpose of the helper file.
Anyone have any suggestions.
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: Converting C#.net to VB.net
May 16, 2012 07:37 AM|LINK
Here's the correct syntax for the helper in VB:
@Helper MakeNote(content As String) @<div class="note" style="border: 1px solid black; width: 90%; padding: 5px; margin-left: 15px;"> <p> <strong>Note</strong> @content </p> </div> End HelperNotice that the parameter is declared in a different way (content As String) in VB, compared to the C# way (string content).
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
timb1021
Member
3 Points
9 Posts
Re: Converting C#.net to VB.net
May 17, 2012 12:50 AM|LINK
Thanks, that worked. I think I tried everything but that.
Thanks again.