Convert C# (with typed events) to VB.NET

后端 未结 4 817
太阳男子
太阳男子 2021-01-07 11:23

I have an ASPX page (with VB Codebehind). I would like to extend the GridView class to show the header / footer when no rows are returned.

I found a C# example onli

相关标签:
4条回答
  • 2021-01-07 11:51

    Please see here.

    There is no exact equivalent to this for VB.

    Use a 'Sub' delegate with a 'ByRef' parameter instead.

    A follow-up answer gives an example that works, but explains why it's a bad idea.

    0 讨论(0)
  • 2021-01-07 11:56

    Concerning 1, the cleanest VB way would be

    If TypeOf data Is System.Data.DataView Then
    
    0 讨论(0)
  • 2021-01-07 11:58

    As I said in my comment the code will not convert to VB.Net "magically". It will require working thru it to get it to compile properly.

    The easiest would be to compile the the C# code as a library.

    1. Create a new project (C# Class Library) and name it "AlwaysShowHeaderFooter"
    2. Move the files from App_Code over to the new project
    3. Add a reference to System.Web and System.Configuration
    4. Add a reference in your web project to either the compiled dll's of "AlwaysShowHeaderFooter", or add the project itself as a reference if you have it in the same solution.
    5. Switch out <%@ Register TagPrefix="Custom" Namespace="AlwaysShowHeaderFooter" %> with <%@ Register Assembly="AlwaysShowHeaderFooter" Namespace="AlwaysShowHeaderFooter" TagPrefix="Custom" %>

    Now you have split the control out to it's own project which can be referenced in any .Net project.

    0 讨论(0)
  • 2021-01-07 11:59

    Regarding 2. I think events in VB.Net can pass ByRef parameters.

    0 讨论(0)
提交回复
热议问题