jquery - take several values from textboxes -
im using mvc 3.0 .net 4.0, razor , kendo ui framework.
i have tree textboxes , need take values each 1 , passing mvc controller.
i cannot receive values textboxes.
ie:
file.cshtml
<input type="text" id="tb0" /> <input type="text" id="tb1" /> <input type="text" id="tb2" /> <button type="submit" id="btnsave">send</button>
jsfile.js
$('#btnsave').click(function (e) { e.preventdefault(); var variable1 = new array(); //i dont know how send values controller variable1[0] = $('#tb0').val(); variable1[1] = $('#tb1').val(); variable1[2] = $('#tb2').val(); var model = { representative1: variable1 } $.ajax({ url: rootfolder + 'controller1/method1', type: 'post', data: json.stringify(model), datatype: 'json', processdata: false, contenttype: 'application/json; charset=utf-8', success: onsuccesssave, error: function (jqxhr, textstatus, errorthrown) { alert(genericerror); } }); }
class1.cs
public class class1 { public class1() { this.representative1 = new representative(); } public int id { get; set; } public string nombre { get; set; } public representative representative1 {get; set;} }
representant.cs
public class representative { public string tb0 { get; set; } public string tb1 { get; set; } public string tb2 { get; set; } }
controller1.cs
public class controller1 { [httppost] public jsonresult method1 (class1 model) { //the "model" var dont receive textboxes values. return json(model, jsonrequestbehavior.allowget); } }
Comments
Post a Comment