-
Feb 24th, 2018, 02:31 PM
#1
Thread Starter
Junior Member
Converting C# Razor to VB.NET
Hi guys i was wondering if someone can covert this to vb.net
@using MyWebApplication.Toast
@if (TempData.ContainsKey("Toastr"))
{
Toastr toastr = TempData["Toastr"] as Toastr;
@ToastrBuilder.ShowToastMessages(toastr);
}
Thanks.
-
Feb 24th, 2018, 04:38 PM
#2
Re: Converting C# Razor to VB.NET
Does Razor support Vb.NET? If it doesn't it won't matter if it can be converted or not.
-tg
-
Feb 24th, 2018, 05:59 PM
#3
Re: Converting C# Razor to VB.NET
Hi,
Not tested this but something like
Code:
@Imports MyWebApplication.Toast
@If TempData.ContainsKey("Toastr") Then
Toastr toastr = DirectCast(TempData("Toastr") ,Toastr)
@ToastrBuilder.ShowToastMessages(toastr)
End If
should work.
That is pretty much a literal translation, not sure if you need all the "@" or more of them under VB
-
Feb 24th, 2018, 07:43 PM
#4
Thread Starter
Junior Member
Re: Converting C# Razor to VB.NET
Very good,
I need to excecute a javascript
<script>
$(function () {
{
@If (TempData.ContainsKey("Notifications")) Then
Dim toastr As Toastr = TryCast(TempData("Toastr"), Toastr)
Dim messages As UserMessageModel = TryCast(TempData("Notifications"), UserMessageModel)
@For Each Item As UserMessageModel In DirectCast(TempData("Notifications"), List(Of UserMessageModel))
@:showNotification("@Item.Message", "@Item.Title", "@Item.Type")
Next
End IF
}
});
</script>
-
Feb 24th, 2018, 08:19 PM
#5
Re: Converting C# Razor to VB.NET
Not entirely sure what that last snippet is trying to achieve, you seem to be just embedding razor code inside a script tag, the two are not the same thing. You can certainly use Razor to generate javascript but that doesn't look like what the code you posted is trying to do.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|