this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

Last post 04-07-2008 4:38 PM by Chuwanga. 4 replies.

Sort Posts:

  • Hmm [^o)] this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

    04-04-2008, 3:33 PM
    • Loading...
    • alivemedia
    • Joined on 06-21-2006, 9:34 PM
    • Posts 45

    How do I do this in VB.net:
    <% using Html.Form<ProductController>(p=>p.Update(ViewData.Produc t.ProductID))%>

    This is using a lambda for the form tag in c#, I searched everywhere for the correct vb.net syntax?

     I tried this with no luck:
    <% Using Html.Form(Of ProductController)(Function(p) p = ViewData.Product.ProductID)%>



     

    Filed under:
  • Re: this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

    04-05-2008, 12:27 AM
    • Loading...
    • nberardi
    • Joined on 06-14-2002, 4:58 AM
    • Phoenixville, PA
    • Posts 2,352

    VB.NET doesn't support Lambda expressions.   

    View My Blog Download My URL Rewriter and Reverse Proxy

    Only $9.95/month, ASP.NET, 2GB & SQL 2005
  • Re: this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

    04-05-2008, 1:01 AM
    • Loading...
    • levib
    • Joined on 07-23-2007, 7:50 PM
    • Redmond, WA
    • Posts 216
    • AspNetTeam

    alivemedia:
    Function(p) p = ViewData.Product.ProductID

    I think the proper syntax is Function(p) p.Update(ViewData.Product.ProductID).

    Check http://msdn2.microsoft.com/en-us/library/cc138590.aspx for more info.  Honestly, though, if the syntax isn't familiar to you I'd recommend using one of the other overloads that doesn't use a lambda.  It'll save you time trying to decipher it when you have to go back and look at it in the future. :)

  • Re: this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

    04-05-2008, 9:56 AM
    • Loading...
    • alivemedia
    • Joined on 06-21-2006, 9:34 PM
    • Posts 45

    Thanks, I tried that syntax with no luck :(

     I will have to go back later and update this stuff, just trying to get it right from the get go. 

    having the same problem with the ActionLink helper

  • Re: this in vb.net: <% using Html.Form<ProductController>(p=>p.Update(ViewData.Product.ProductID))%>

    04-07-2008, 4:38 PM
    Answer
    • Loading...
    • Chuwanga
    • Joined on 03-14-2008, 1:30 PM
    • Edinburgh
    • Posts 3

    Hello alivemedia!

     You're right the lack of lambda-support in VB.NET is really ackward. I use a syntax that works, but is far to long to be nicely readable, but it gives you the benefit of refactoring-support:

      

    <%Using Html.Form(Of CustomerController)(New System.Action(Of CustomerController) _
    (Function(c As CustomerController) c.Login()), FormMethod.Post)%> <%-- FORM CONTENT --%> <%End Using %>

     

    As a workaround you need to declare the methods, which you want to use in your Html.Form() call (here it is Login() in my CustomerController class), as functions of type object (or something) else and just return Nothing in the respective Method. This worked for me. A sample Login() method would look as follows:

     

    1    Public Class CustomerController
    2        Inherits System.Web.Mvc.Controller
    3    
    4      Public Function Login() As Object
    5    
    6         RenderView("Login")
    7         Return Nothing
    8    
    9      End Function
    10   
    11   End Class
    

     

     Hope I could help!

     Greetings,

    Jimmy

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter