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
}
Iftikar HussainPosted Jul 26, 2013, 8:49 AM
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,
jojo cadientePosted Jul 26, 2013, 8:27 AM
Sandeep Singh ShekhawatPosted Jul 26, 2013, 8:09 AM
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 cadientePosted Jul 26, 2013, 6:16 AM
Akhil MittalPosted Jul 26, 2013, 5:39 AM
}
Mark as answer if this helps u.