Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:39:30+00:00 2026-05-28T02:39:30+00:00

I did the web method below using C#. I’m tryin to convert this into

  • 0

I did the web method below using C#. I’m tryin to convert this into VB.NET, but I’m missing something. I’m using it with an ajax calling, from a paginator/sorter table plugin.

[WebMethod( EnableSession = true )]
public static object listaPessoas(int jtStartIndex = 0, 
                                  int jtPageSize = 0, 
                                  string jtSorting = null)
{
    return new { Result = "OK", 
                 Records = persons.ToList(), 
                 TotalRecordCount = persons.count };
}

First, error in VB – I can’t leave the parameters as optional(“Attribute WebMethod cannot be applied to a method with optional parameters“):

<WebMethod()> _
Public Function listaPessoas(Optional ByVal jtStartIndex As Integer = 0, 
                             Optional ByVal jtPageSize As Integer = 0, 
                             Optional ByVal jtSorting As String = Nothing)

Second, I don’t know how to return the message “OK” and the list of people.

Can anyone me help to convert this into VB.NET?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:39:31+00:00Added an answer on May 28, 2026 at 2:39 am

    Seems like you can’t use optional parameters with WebMethods. You can use overloading. Example:

    <WebMethod()> _
    Public Function listaPessoas(jtStartIndex As Integer, jtPageSize As Integer)
    
    <WebMethod()> _
    Public Function listaPessoas(jtStartIndex As Integer, jtPageSize As Integer, jtSorting As String)
    

    The C# object returned is an anonymous object. The VB syntax is:

    Return New With { .Result = "OK", 
                      .Records = persons.ToList(), 
                      .TotalRecordCount = persons.count }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am stress testing a .NET web application. I did this for 2 reasons:
Did anyone encountered this exception while using Jena in Java Web Application... Please Kindly
I did a small web application for using PHP, HTML, and JavaScript. I want
Ok so I need to download some web pages using Python and did a
Hello i did my notification of download file from web. Code below. I want
Reference to previous question: Getting an ajax response in java from a web method
What internal web service did your company implement first? What did you learn?
Lot of googling did not help me! Are there any good dictionary web based
I am needing to create a web service, so the first thing I did
I did notice a few related questions to this problem (I also did a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.