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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:57:40+00:00 2026-05-29T07:57:40+00:00

I am sending a DTO to a web service using JQuery, but i need

  • 0

I am sending a DTO to a web service using JQuery, but i need to know how to iterate through the object when received at the web service call. Here is the code

JQUERY

$(divButtonText).click(function() {

            var QuestionItems = {};
            var foundEmptyFields = false;
            var count = 1;
            $(".diverror").hide();

            $(".cmsquestions").each(function() {

                var question = $($(this).find(".cmstextbox input")).val();
                var radioValue = $($($('input[name="responsefields' + count + '"]:checked')).next()).text();

                if (question.length > 0) {

                    var questionnumber = $(".cmspagenumber").length;

                    if (questionnumber == 0) {

                        questionnumber = 1;
                    }

                    var QuestionItem = {};

                    QuestionItem.TitleID = data.d;
                    QuestionItem.Number = questionnumber;
                    QuestionItem.Question = question;
                    QuestionItem.FieldType = radioValue;

                    QuestionItems[count - 1] = QuestionItem;
                }
                else {
                    foundEmptyFields = true;
                    var error = $(this).find(".diverror");
                    $(error).show();
                }

                count += 1;

            });

            if (!foundEmptyFields) {



                var DTO = { 'QuestionItems': QuestionItems };
                var param = JSON.stringify(DTO);
                Ajax_WebService(param, 'AddQuestion', AddQuestionServerResponse);

            }

        });

WEBMETHOD

 <WebMethod()> _
  Public Function AddQuestion(ByVal QuestionItems As Object) As Integer

    For i As Integer = 0 To QuestionItems.Count - 1



    Next


End Function

EDIT

WEB Service Call

function Ajax_WebService(param, method, callback) {

$.ajax({
    type: "POST",
    url: "CMSAdmin.asmx/" + method,
    data: param,
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    success: function(data) {
        if (callback) {
            callback.call(null, data);
        }

    }
});

}

EDIT

Ok i have changed the WebMethod to this

 <WebMethod()> _
 Public Function AddQuestion(ByVal QuestionItems As List(Of QuestionItem)) As Integer




End Function

I can now possibly iterate through the list items but my QuestionItem class is picking up values of nothing and empty, the QuestionItem class is here

Public Class QuestionItem


    Private _TitleID As Integer
    Private _Number As Integer
    Private _Question As String
    Private _FieldType As String

    Public ReadOnly Property TitleID() As Integer
        Get
            Return Me._TitleID
        End Get
    End Property

    Public ReadOnly Property Number() As Integer
        Get
            Return Me._Number
        End Get
    End Property

    Public ReadOnly Property Question() As String
        Get
            If Me._Question Is Nothing Then
                Return String.Empty
            End If
            Return Me._Question
        End Get
    End Property

    Public ReadOnly Property FieldType() As String
        Get
            If Me._FieldType Is Nothing Then
                Return String.Empty
            End If
            Return Me._FieldType
        End Get
    End Property
End Class

Why is the properties returning null and empty values from the JSON Object, that class structure is the same as the JSON Class Structure?

  • 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-29T07:57:41+00:00Added an answer on May 29, 2026 at 7:57 am

    This is the WebMethod call that uses QuestionItem Class to set the values from the JSON Request

    <WebMethod()> _
     Public Function AddQuestion(ByVal QuestionItems() As QuestionItem) As Integer
    
    
        For Each item As QuestionItem In QuestionItems
    
    
    
    
        Next
    
    
    End Function
    
    Public Class QuestionItem
    
    
        Private _TitleID As Integer
        Private _Number As Integer
        Private _Question As String
        Private _FieldType As String
    
        Public Property TitleID() As Integer
            Get
                Return Me._TitleID
            End Get
            Set(ByVal value As Integer)
                Me._TitleID = value
            End Set
        End Property
    
        Public Property Number() As Integer
            Get
                Return Me._Number
            End Get
            Set(ByVal value As Integer)
                Me._Number = value
            End Set
        End Property
    
        Public Property Question() As String
            Get
                If Me._Question Is Nothing Then
                    Return String.Empty
                End If
                Return Me._Question
            End Get
            Set(ByVal value As String)
                Me._Question = value
            End Set
        End Property
    
        Public Property FieldType() As String
            Get
                If Me._FieldType Is Nothing Then
                    Return String.Empty
                End If
                Return Me._FieldType
            End Get
            Set(ByVal value As String)
                Me._FieldType = value
            End Set
        End Property
    End Class
    

    The Jquery and Javascript is below of how to format out the JSON Request client side

    $(divButton).click(function() {
    
                var QuestionItems = new Array();
    
                var foundEmptyFields = false;
                var count = 1;
                $(".diverror").hide();
    
                $(".cmsquestions").each(function() {
    
                    var question = $($(this).find(".cmstextbox input")).val();
                    var radioValue = $($($('input[name="responsefields' + count + '"]:checked')).next()).text();
    
                    if (question.length > 0) {
    
                        var questionnumber = $(".cmspagenumber").length;
    
                        if (questionnumber == 0) {
    
                            questionnumber = 1;
                        }
    
                        var QuestionItem = {};
    
                        QuestionItem.TitleID = data.d;
                        QuestionItem.Number = questionnumber;
                        QuestionItem.Question = question;
                        QuestionItem.FieldType = radioValue;
    
                        QuestionItems.push(QuestionItem);
                    }
                    else {
                        foundEmptyFields = true;
                        var error = $(this).find(".diverror");
                        $(error).show();
                    }
    
                    count += 1;
    
                });
    
                if (!foundEmptyFields) {
    
    
    
                    var DTO = "{ 'QuestionItems':" + JSON.stringify(QuestionItems) + "}";
                    var param = DTO;
                    Ajax_WebService(param, 'AddQuestion', AddQuestionServerResponse);
    
                }
    
            });
    
    
    function Ajax_WebService(param, method, callback) {
    
    $.ajax({
        type: "POST",
        url: "CMSAdmin.asmx/" + method,
        data: param,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(data) {
            if (callback) {
                callback.call(null, data);
            }
    
        }
    });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I
I build various web applications in PHP. Clients usually have the need for sending
Hey, I'm using Spring MVC and I got used to sending DTO to a
Sending a message from the Unix command line using mail TO_ADDR results in an
Sending a mail through my windows application to a person asking him to log
When sending data over HTTPS, I know the content is encrypted, however I hear
When sending data via POST or GET with jQuery you use for format {
When sending email using the SMTPClient class in ASP.NET C#, how can I add
When sending data to a stored procedure through SubSonic, how can I pass 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.