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.
Printable View
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.
Does Razor support Vb.NET? If it doesn't it won't matter if it can be converted or not.
-tg
Hi,
Not tested this but something like
should work.Code:@Imports MyWebApplication.Toast
@If TempData.ContainsKey("Toastr") Then
Toastr toastr = DirectCast(TempData("Toastr") ,Toastr)
@ToastrBuilder.ShowToastMessages(toastr)
End If
That is pretty much a literal translation, not sure if you need all the "@" or more of them under VB
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>
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.