jojo cadiente

jojo cadiente

  • NA
  • 8
  • 21.8k

MVC ASP.NET AJAX ACTION LINK CREATE

Jul 26 2013 5:04 AM
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
}
         


Answers (5)