dcsimg
Results 1 to 5 of 5

Thread: Converting C# Razor to VB.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    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.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,949

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    888

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    14

    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>

  5. #5
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    888

    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
  •  



Featured


Click Here to Expand Forum to Full Width