ahmed salah

ahmed salah

  • NA
  • 530
  • 141k

when pass variable ids from view to controller give me null

Oct 28 2016 9:52 AM
Problem in server side(controller)


pass value of ids from view to controller give me null value in controller when i check in break point although it have value in client side jquery
  1. public ActionResult Edit(FormCollection form)  
  2. {  
  3. // check string ids give me null value although text box ids have value in view  
  4.   
  5. string ids = form["ids"];  
  6. return View();  
  7. }  
This variable ids represent as text box in view and i check it in view it have values. this text box have values after i remove courses from table it send removed courses ids to text box ids .
  1. $("#tb").on("click"".r"function () {  
  2. $(this).parent().parent().hide();  
  3. $(this).parent().prev().prev().find("input").addClass("remove");  
  4. var ids = [];  
  5. var i = 0;  
  6. $(".remove").each(function () {  
  7. ids[i] = $(this).val();  
  8. i++;  
  9. });  
  10. $("#ids").val(ids);  
  11. });  
  12. @using (Html.BeginForm())  
  13. {  
  14. <div>  
  15. <table id="tb"></table>  
  16. <input type="submit" value="save" />  
  17. <input type="text" name="ids" id="ids" />  
  18. </div>  
  19. <table id="tb">  
  20.   
  21. </table>  
  22. }  
see image to more clear understand enter image description here

enter image description here

 

Answers (4)