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 7441855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:05:02+00:00 2026-05-29T11:05:02+00:00

I use jQuery ajax calls to ASP.Net web services (ASMX files) to update the

  • 0

I use jQuery ajax calls to ASP.Net web services (ASMX files) to update the web page data.

I have the database storing code seperate from the domain object class code (in the example code below, there is an Animal class and an AnimalRepository class). I’m implememting a convention that all similar domain object repository classes will have a Store method .

I would like to create a web service that can cater for calling the Store method for any one of these repository classes. To get this to work, in the below code sample, the List(Of Animal) parameter would need to be a generic type.

I tried a List(Of Object), but the Store command errors on not able to convert types. I don’t think I can cast the List(Of Object) to the right type, as it’s not known until runtime.

    <WebMethod(True)> _
Public Sub StoreAnimals(ByVal _animals As List(Of Animal), ByVal _type As String)
    Dim classType As Type = Type.GetType(_type & "Repository, MyCompany.Assembly")
    Dim instanceOfClass = Activator.CreateInstance(classType)
    Dim method As MethodInfo = classType.GetMethod("Store")
    method.Invoke(instanceOfClass, New Object() {_animals})
End Sub

Ideally, I would like:

    <WebMethod(True)> _
Public Sub StoreData(Of T)(ByVal _data As List(Of T), ByVal _type As String)
    Dim classType As Type = Type.GetType(_type & "Repository, MyCompany.Assembly")
    Dim instanceOfClass = Activator.CreateInstance(classType)
    Dim method As MethodInfo = classType.GetMethod("Store")
    method.Invoke(instanceOfClass, New Object() {_data})
End Sub

There’s no room for generics in the webservice method definition, but is there a trick to achieve the same end result.
Otherwise, I’m going to be creating lots of these Store* webservices that only differ on the first parameter.

  • 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-29T11:05:03+00:00Added an answer on May 29, 2026 at 11:05 am

    Generics have no meaning in the web services world.

    You can’t come anywhere close to this with ASMX. With WCF, you might be able to do something, but you can’t use an open generic type in an operation contract.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I have an asp.net user control on which I want to use jquery ajax.
I have an ASP .NET page where I use jQuery. I used this function
If I use jQuery AJAX to call a specific ASP.NET page method how to
I am trying to use jQuery's ajax functionality to update data from a web
We've an ASP.Net MVC2 web app (SQL 2008 in backend). We use Data Annotations
I'm building an ASP.NET MVC site where I want to implement jQuery AJAX calls
I have an ASP.NET MVC 3 (.NET 4) web application. This app fetches data
I'm trying to decide whether to use a custom ASP.Net Ajax Extender or jQuery
I am just trying to learn how to use JQuery AJAX with ASP.NET MVC

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.