Hello could anybody Help me about passing the value of a textbox from form using Ajax Actionlink. It's been whole day figuring out still I'm getting value of null.
Im using pure Ajax Action link with out Any button.
here is the sample of delete ajax action link works perfect!
http://www.joe-stevens.com/2010/02/16/creating-a-delete-link-with-mvc-using-post-to-avoid-security-issues/
But using it in form collection the value always null. Any help Appreciated Thanks!
here is my code:
CustomerVIEW
<% using (Html.BeginForm())
{ %>
<%= Html.TextBoxFor(model => model.Fname, new { id = "Fname" })%>
<%= Html.TextBoxFor(model => model.Lname, new { id = "Lname"})%>
<%= Ajax.ActionLink("Create", "Create",
new { id = 1},
new AjaxOptions {
HttpMethod="POST",
OnFailure = "function() { alert('fail'); }",
OnSuccess = "function() { alert('success'); }"
})%>
}
------------------------------------------------------------------------
CustomerController
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection formCollection)
{
clsCustomer objcustomer = new clsCustomer();
clsSession objSession = new clsSession();
objcustomer.Fname = formCollection["Fname"]; --> NULL
objcustomer.Lname = formCollection["Lname"]; --> NULL
}

Akhil MittalRank #133 · 16.9K reputationPosted Jul 26, 2013, 1:39 AM EDT
}
Mark as answer if this helps u.
jojo cadiente8 reputationPosted Jul 26, 2013, 2:16 AM EDT
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Jul 26, 2013, 4:09 AM EDT
You need to create an function that would be return customer details which would be "clsCustomer" retrun type as your model.
Now you have details in model then assign value to properties. You need to pass only id in create method.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(int id)
{
clsCustomer objcustomer = new clsCustomer();
clsSession objSession = new clsSession();
var model = getCustomrtById(id);
objcustomer.Fname = model.Fname;
objcustomer.Lname = model.Lname;
}
jojo cadiente8 reputationPosted Jul 26, 2013, 4:27 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 26, 2013, 4:49 AM EDT
Please refer the below link
http://www.codeproject.com/Articles/165410/ASP-NET-MVC-Editable-DataTable-jQuery-DataTables-a
http://mvc-tutorials.com/asp-net-mvc-webgrid-with-paging-sorting-edit-and-delete-commands
Regards,