1

I have a pretty big data entry form which has many text fields , ComboBox , etc. When I want to Do an action with jQuery AJAX for example posting Fields to a WebService for inserting a new record I have to put all input fields in a object and passing it to WebService. For example I have Member Class Like This :

public class Member
{
    private string name = String.Empty;
    private string lastName = String.Empty;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    public string LastName
    {
        get { return lastName; }
        set { lastName = value; }
    }
}

I Should Define JS object Client Side and filling Properties like this :

var m = new Member();
m.Name = $("#txtFirstName").val();
m.LastName = $("#txtFirstName").val();

after that I should pass object to a Webservice and doing my serverSide Action. So it is simple when I have under ten fields . but when I have for example twenty fields it takes long time to capture all fields from client and passing that to server. Now my questions :

  1. What are other ways to handle data entry form and passing Input fields to server?
  2. Is there any framework or tool exist to make this action easier for us ? I will welcome your suggestions, comments.
Shahin
  • 12,543
  • 39
  • 127
  • 205

1 Answers1

2

Have you tried using the jQuery serialize() method?

The .serialize() method creates a text string in standard URL-encoded notation. It operates on a jQuery object representing a set of form elements. The form elements can be of several types:

$('form').submit(function() {
    alert($(this).serialize());
    return false;
});

You could also use the example in this SO answer: Convert form data to JavaScript object with jQuery

Community
  • 1
  • 1
hunter
  • 62,308
  • 19
  • 113
  • 113