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 :
- What are other ways to handle data entry form and passing Input fields to server?
- Is there any framework or tool exist to make this action easier for us ?
I will welcome your suggestions, comments.
Have you tried using the jQuery serialize() method?
You could also use the example in this SO answer: Convert form data to JavaScript object with jQuery