How to use IsPostBack in MVC-4 - asp.net-mvc

I want to don't bind my dropdown list if the form state is post back. As you can see in my code I have two forms and two submit buttons. I want to keep selected value of dropdownlist after I click second submit button.
<form method="POST" action="#Url.Action("UserRoles", "PageUserRole")">
<label>Kullanıcı Grubu</label>
#Html.DropDownList("Id", Utility.GetUserGroups(), "Kullanıcı Grubu Seçiniz.")
<input type="submit" value="Listele" />
</form>
....
<form method="POST" action="#Url.Action("EditUserRoles", "PageUserRole")">
<table>
<tbody>
<tr>
<td>
İşlem
</td>
<td>
Yetki
</td>
</tr>
#for (int i = 0; i < Model.PageMenUsuserRoles.Count; i++)
{
<tr>
<td>
#Model.PageMenUsuserRoles[i].pagemenu.Name
</td>
<td>
#Html.Hidden("PageMenUsuserRoles[" + i + "].Id", Model.PageMenUsuserRoles[i].Id)
#Html.CheckBox("PageMenUsuserRoles[" + i + "].CanView", Model.PageMenUsuserRoles[i].CanView)
</td>
</tr>
}
<tr>
<td colspan="2">
<input type="submit" value="Kaydet" />
</td>
</tr>
</tbody>
</table>
</form>

Related

MVC How to pass label data from view to controller?

I am trying to pass data from view to controller. I used BeginForm and i can pass data which users enter to textbox. But I want to also pass label data because label is filled automatically and i need to save this label text to database. How can i do?
View:
#using (Html.BeginForm("Room", "Booking", FormMethod.Post))
{
<table>
<tr>
<td align="left"><lable for="eventName">Description:</lable></td>
<td><input name="eventName" id="eventName"></td>
</tr>
<tr>
<td align="left"><lable for="startDate">Start Date : </td>
<td align="left"><label id="startDate" name="startDate" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="right" colspan="2">
<button type="submit" class="btn-primary" name="submit" id="submit">Save</button>
</td>
</tr>
<tr>
</tr>
</table>
}
Controller:
[HttpPost]
public ActionResult Room(FormCollection form)
{
using (BookingEntities ent = new BookingEntities ())
{
ReservationTBL Tbl = new ReservationTBL();
Tbl.Description = form["eventName"].ToString();
Tbl.startDate= form["startDate"].ToString();
ent.BookingTBL.Add(Tbl);
ent.SaveChanges();
}
return View();
}
The label data doesn't get send when you post your form. What you can do however is to add an input with type hidden that contains your label data.
Something like this:
<tr>
<td align="left"><label for="startDate">Start Date : </td>
<td align="left">
<label>#Model.StartDate</label>
<input type="hidden" name="startDate" value="#Model.StartDate" id="startDate"/>
</td>
</tr>

POST action returns the model in a valid state but returns Model.Count as 0 when using foreach or for loop

As shown in my post here the GET action method Test(..) works fine when using foreach loop in the corresponding Test.chtml view but the POST action method Test(...) returns null. But, as mentioned by many users, the foreach is not reliable for POST method. So, I decided to use the for loop as shown below. But that returned unexpected results in the view since, according to this post, in a foreachloop type casting is done automatically but in for loop you have to type cast the objects Model[i].BlogID etc to a proper class object type.
So, I decided to type cast the objects Model[i].BlogID etc to a BlogsWithRelatedPostsViewModel class object type as shown in the second version of Test.cshml view below; and this time the Test.cshtml view is displayng the correct records. But although the submit button in the view is sending a a valid model (ModelState.IsValid is true) the Model.Count is 0 that results in no update to database. Why Model.Count is 0 and how to correct it? As you can see below the html page source of the view is showing the name attributes of the tags matching the property values in the View Model.
Note: For complete code, please see this OP. I'm using ASP.NET Core with EF Core and Tag Helpers.
Test.cshtml view with for loop - without type casting the loop objects:
#model IList<ASP_Core_Blogs.Models.BlogPostViewModels.BlogsWithRelatedPostsViewModel>
#using ASP_Core_Blogs.Models.BlogPostViewModels
#{ ViewData["Title"] = "Index"; }
<div class="row">
<div class="col-md-12">
<form asp-controller="Blogs" asp-action="Test" asp-route-returnurl="#ViewData["ReturnUrl"]" method="post">
#{
IEnumerable<SelectListItem> yearsList = (IEnumerable<SelectListItem>)ViewBag.YearsList;
var currentlySelectedIndex = 0; // Currently selected index (usually will come from model)
}
<strong>Select a Post Year</strong>
<h6>Choose a year and a URL to begin:</h6>
<label>Year:</label><select asp-for="#currentlySelectedIndex" asp-items="yearsList"></select><input type="submit" class="btn btn-default" name="GO" value="GO" />
<table class="table">
<thead>
<tr>
<th></th>
<th></th>
<th>Url</th>
<th>Title</th>
<th>Content</th>
</tr>
</thead>
<tbody>
#for (int i=0; i< Model.Count(); i++)
{
<tr>
<td><input type="hidden" asp-for="#Model[i].BlogID" /></td>
<td><input type="hidden" asp-for="#Model[i]).PostID" /></td>
<td>
<input type="text" asp-for="#Model[i].Url" style="border:0;" readonly />
</td>
<td>
<input asp-for="#Model[i].Title" />
</td>
<td>
<input asp-for="#Model[i].Content" />
</td>
</tr>
}
</tbody>
</table>
<button type="submit" class="btn btn-default">Save</button>
</form>
</div>
</div>
Test.cshtml view with for loop objects being casted as BlogsWithRelatedPostsViewModel class objects:
#model IList<ASP_Core_Blogs.Models.BlogPostViewModels.BlogsWithRelatedPostsViewModel>
#using ASP_Core_Blogs.Models.BlogPostViewModels
#{ ViewData["Title"] = "Index"; }
<div class="row">
<div class="col-md-12">
<form asp-controller="Blogs" asp-action="Test" asp-route-returnurl="#ViewData["ReturnUrl"]" method="post">
#{
IEnumerable<SelectListItem> yearsList = (IEnumerable<SelectListItem>)ViewBag.YearsList;
var currentlySelectedIndex = 0; // Currently selected index (usually will come from model)
}
<strong>Select a Post Year</strong>
<h6>Choose a year and a URL to begin:</h6>
<label>Year:</label><select asp-for="#currentlySelectedIndex" asp-items="yearsList"></select><input type="submit" class="btn btn-default" name="GO" value="GO" />
<table class="table">
<thead>
<tr>
<th></th>
<th></th>
<th>Url</th>
<th>Title</th>
<th>Content</th>
</tr>
</thead>
<tbody>
#for (int i=0; i< Model.Count(); i++)
{
<tr>
<td><input type="hidden" asp-for="((BlogsWithRelatedPostsViewModel)#Model[i]).BlogID" /></td>
<td><input type="hidden" asp-for="((BlogsWithRelatedPostsViewModel)#Model[i]).PostID" /></td>
<td>
<input type="text" asp-for="((BlogsWithRelatedPostsViewModel)#Model[i]).Url" style="border:0;" readonly />
</td>
<td>
<input asp-for="((BlogsWithRelatedPostsViewModel)#Model[i]).Title" />
</td>
<td>
<input asp-for="((BlogsWithRelatedPostsViewModel)#Model[i]).Content" />
</td>
</tr>
}
</tbody>
</table>
<button type="submit" class="btn btn-default">Save</button>
</form>
</div>
</div>
A Portion of html generated by View after Submit:
<tr>
<td><input type="hidden" data-val="true" data-val-required="The BlogID field is required." id="BlogID" name="BlogID" value="1" /></td>
<td><input type="hidden" data-val="true" data-val-required="The PostID field is required." id="PostID" name="PostID" value="1" /></td>
<td>
<input type="text" style="border:0;" readonly id="Url" name="Url" value="blog1#test.com" />
</td>
<td>
<input type="text" id="Title" name="Title" value="Title1" />
</td>
<td>
<input type="text" id="Content" name="Content" value="Content1" />
</td>
</tr>

Can I use resource routes without a database (without ids)

I'm building an UI app that has no models, no database. It uses web-service calls for all of its business logic. I'm having an unbelievably difficult time getting the routing complete. I still have entities like workstations. I've declared in my routes resource :workstations which gives me these routes:
workstations POST /workstations(.:format) workstations#create
new_workstations GET /workstations/new(.:format) workstations#new
edit_workstations GET /workstations/edit(.:format) workstations#edit
GET /workstations(.:format) workstations#show
PUT /workstations(.:format) workstations#update
DELETE /workstations(.:format) workstations#destroy
but when I try to link to an update action like = link_to "Update", workstations_path, :method => :put I get No route matches {:controller=>"workstations", :method=>"put"}. Isn't that the route thats listed for the update action?
I'm wondering if I can't use traditional resourceful routes since I don't have ids. Or maybe I'm just doing it wrong.
View code (Haml):
%h2
%small#application-name-label Technical Support Interface
.col-md-3
%h3 Workstations
%button.btn.btn-success.create-button Create Workstation
- if #workstations.blank?
.no-items-available There are no workstations to display
-else
= form_tag(controller: "workstations", action: "delete_history_and_queue", method: "post") do
%table#workstation-table.table.table-striped.table-hover.table-bordered
%thead
%tr
%th#table-header Name
%th#table-header Delete History
%th#table-header Delete Queue
%th#table-header Update
%th#table-header Delete
%tbody
- #workstations.each do |workstation|
%tr
%td
= workstation[:name]
%td
= check_box_tag 'delete history', form_class: "checkbox"
%td
= check_box_tag 'delete queue', form_class: "checkbox"
%td
= link_to "Update", workstations_path, :action => :update
%td
= link_to "Delete", workstations_path, :action => :destroy
= submit_tag
.col-md-3
%h3 Data Sources
%button.btn.btn-success.create-button Create Data Source
- if #data_sources.blank?
.no-items-available There are no sources to display
-else
%table.table.table-striped.table-hover.table-bordered
%tr
%th#table-header Type
%th#table-header Name
- #data_sources.each do |data_source|
%tr
%td
= data_source[:type]
%td
= data_source[:name]
HTML
<body>
<div class='whole-page'>
<div class='container'>
<h1 class='hero-unit' id='application-title'>
<div class='row-fluid'>
<div class='span1' id='replication-server'>
<img alt="Cog_logo" src="/assets/cog_logo.png" />
<img alt="Crs" src="/assets/crs.png" />
Replication Server
</div>
</div>
</h1>
</div>
</div>
<h2>
<small id='application-name-label'>Technical Support Interface</small>
</h2>
<div class='col-md-3'>
<h3>Workstations</h3>
<button class='btn btn-success create-button'>Create Workstation</button>
<form accept-charset="UTF-8" action="/?method=post" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="NQghiooSVtSngRU7K170uxhqJ2N6i9XQ6sP5W+UeKrY=" /></div>
<table class='table table-striped table-hover table-bordered' id='workstation-table'>
<thead>
<tr>
<th id='table-header'>Name</th>
<th id='table-header'>Delete History</th>
<th id='table-header'>Delete Queue</th>
<th id='table-header'>Update</th>
<th id='table-header'>Delete</th>
</tr>
</thead>
<tbody>
<tr>
<td>
consequatur
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
quia
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
quod
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
reprehenderit
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
laborum
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
quidem
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
laboriosam
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
<tr>
<td>
non
</td>
<td>
<input id="delete_history" name="delete history" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
<input id="delete_queue" name="delete queue" type="checkbox" value="{:form_class=>"checkbox"}" />
</td>
<td>
Update
</td>
<td>
Delete
</td>
</tr>
</tbody>
</table>
</form>
<input name="commit" type="submit" value="Save changes" />
</div>
<div class='col-md-3'>
<h3>Data Sources</h3>
<button class='btn btn-success create-button'>Create Data Source</button>
<table class='table table-striped table-hover table-bordered'>
<tr>
<th id='table-header'>Type</th>
<th id='table-header'>Name</th>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
http://block.com/keaton_baumbach
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
http://wolff.info/jace_rice
</td>
</tr>
</table>
</div>
</body>
</html>
You can certainly use restful routes w/o model objects or ids. Everything you have seems just fine, I even tried it locally, worked.
If you're testing using rails s, you may want to re-start, I've had routing issues in the past that a re-start fixed.

Append an entire form using jquery in an absolute position

Just need to know how to append this entire html on a button click. I'm trying to create a list and display it over the page. .......................................................................................................................................
#Html.BeginForm(null, null, FormMethod.Get, new { name = "vouchers", id = "vouchers" })
<h2>Voucher</h2>
<div class="whole">
<div class ="top">
<label class ="lbl" >Assign a voucher Number </label>
<input type ="text" class="txt"/>
</div>
<div class="mid">
<div class ="tdes">
<table class="vtab">
<tr class="heading">
<td>
Date
</td>
<td>
Name
</td>
<td>
Category
</td>
<td>
Amount
</td>
<td>
To Account
</td>
</tr>
#foreach (var item in Model) {
<tr class="rows">
<td>
#item.Date.ToShortDateString()
</td>
<td>
#Html.DisplayFor(modelItem => item.Per)
</td>
<td>
#Html.DisplayFor(modelItem => item.CId)
</td>
<td>
#Html.DisplayFor(modelItem => item.Amt)
</td>
<td>
#Html.DisplayFor(modelItem => item.AId)
</td>
</tr>
}
</table>
</div>
</div>
<div class="bot">
<input type ="submit" value="Save" class ="btn" id ="save" />
<input type ="submit" value ="Print" class="btn" id ="print" />
</div>
</div>
}
How about using jQuery UI Dialog:
$("#vouchers").dialog({
autoShow: false,
// Other options
});
$("#somebutton").click(function() {
$("#vouchers").dialog("show");
});

getting MVC 2 form values in controller action using jquery ajax

I am working on asp.net MVC 2 application. I have a form like this:
<% using (Html.BeginForm("UpdateRecordingDetails", "Recording", FormMethod.Post, new { id = "frmRecordingEdit" }))
{%>
<%= Html.Hidden("AccountIDsEdit", ViewData["AccountIDsEdit"]) %>
<%= Html.Hidden("SelId", ViewData["SelId"]) %>
<%= Html.Hidden("EditMode", ViewData["EditMode"]) %>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr valign="top">
<td>
<table align="center">
<tr>
<td style="width: 32%;">
<%=Html.HiddenFor(model=>model.Id) %>
<b>Person Name</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.PersonName, new { #class = "textarea wide" , disabled ="disabled"})%>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Email</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.Email, new { #class = "textarea wide" })%>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Notes</b>
</td>
<td>
<%: Html.TextAreaFor(model => model.Notes, new { #class = "textarea widetextarea" })%>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Display Notes on Playback</b>
</td>
<td>
<%: Html.DropDownList("isNotesVisible", ViewData["displayNotes"] as SelectList, new {#class = "normal" })%>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Call ID Number</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallIDNumber, new { #class = "textarea normal", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Dblink Unique URL</b>
</td>
<td>
<span id="DBLinkUniqueURL" class="small">
<%= Model.DBLinkUniqueURL %>
</span>
<input id="btnCopy" type="button" value="Copy to Clipboard" onclick="copyToClipboard('DBLinkUniqueURL')" />
</td>
</tr>
<tr>
<td>
<b>Call Password</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallPassword, new { #class = "textarea wide", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Number Called</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.NumberCalledFrom, new { #class = "textarea wide", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Called From</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.NumberCalledTo, new { #class = "textarea wide", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Call Duration</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallDuration, new { #class = "textarea normal", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Call Rate</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallRate, new { #class = "textarea normal", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Call Cost</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallCost, new { #class = "textarea tiny", disabled = "disabled" })%>
<%: Html.TextBoxFor(model => model.CallCost, new { #class = "textarea normal", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>User ID/ Email</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.LoginId, new { #class = "textarea wide", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Date/Time Added</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CreationDate, new { #class = "textarea wide", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Call Status</b>
</td>
<td>
<%: Html.TextBoxFor(model => model.CallStatus, new { #class = "textarea normal", disabled = "disabled" })%>
</td>
</tr>
<tr>
<td>
<b>Archived</b>
</td>
<td>
<%: Html.CheckBoxFor(model => model.isArchived, new { disabled = "disabled"})%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
}
%>
I have a button outside this form, which posts the form with jquery ajax like this:
function editAccountDetails() {
jQuery.ajax({
url: "/recording/UpdateRecordingDetails",
type: 'POST',
data: $('frmRecordingEdit').serialize(),
dataType: "json",
contentType: "application/json",
success: function (data) {
alert(data);
}
});
}
In controller action method, I am not getting all these fields. I get only the ones which are in viewdata or which are not disabled and checkbox value. My action method is:
[Authorize]
public ActionResult UpdateRecordingDetails(FormCollection form, CallRecordingModel objCampaignMode)
{
return Content("testing");
}
neither formcollection note the model has all the fields values which are in the form.
[Edit]
form has values for
AccountIDsEdit
SelId
EditMode
Id
Email
Notes
isNotesVisible
isArchived
model has values in three fields
email, Id, notes
<td>
<table align="center">
<tbody><tr>
<td style="width: 32%;">
<input type="hidden" value="2" name="Id" id="Id">
<b>Person Name</b>
</td>
<td>
<input type="text" value="Asif" readonly="readonly" name="PersonName" id="PersonName" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Email</b>
</td>
<td>
<input type="text" value="asif#cc.com" name="Email" id="Email" class="textarea wide">
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Notes</b>
</td>
<td>
<textarea rows="2" name="Notes" id="Notes" cols="20" class="textarea widetextarea">asif notes</textarea>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Display Notes on Playback</b>
</td>
<td>
<select name="isNotesVisible" id="isNotesVisible" class="normal"><option selected="selected">Yes</option>
<option>No</option>
</select>
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Call ID Number</b>
</td>
<td>
<input type="text" value="callIDNum002" name="CallIDNumber" id="CallIDNumber" disabled="disabled" class="textarea normal">
</td>
</tr>
<tr>
<td style="width: 32%;">
<b>Dblink Unique URL</b>
</td>
<td>
<span class="small" id="DBLinkUniqueURL">
http://temp.com/callIDNum002
</span>
<input type="button" onclick="copyToClipboard('DBLinkUniqueURL')" value="Copy to Clipboard" id="btnCopy">
</td>
</tr>
<tr>
<td>
<b>Call Password</b>
</td>
<td>
<input type="text" value="temppass" name="CallPassword" id="CallPassword" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td>
<b>Number Called</b>
</td>
<td>
<input type="text" value="03344037289" name="NumberCalledFrom" id="NumberCalledFrom" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td>
<b>Called From</b>
</td>
<td>
<input type="text" value="0442510406" name="NumberCalledTo" id="NumberCalledTo" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td>
<b>Call Duration</b>
</td>
<td>
<input type="text" value="00:01:30" name="CallDuration" id="CallDuration" disabled="disabled" class="textarea normal">
</td>
</tr>
<tr>
<td>
<b>Call Rate</b>
</td>
<td>
<input type="text" value="4" name="CallRate" id="CallRate" disabled="disabled" class="textarea normal">
</td>
</tr>
<tr>
<td>
<b>Call Cost</b>
</td>
<td>
<input type="text" value="3" name="CallCost" id="CallCost" disabled="disabled" class="textarea tiny">
<input type="text" value="3" name="CallCost" id="CallCost" disabled="disabled" class="textarea normal">
</td>
</tr>
<tr>
<td>
<b>User ID/ Email</b>
</td>
<td>
<input type="text" value="asif_hameed_371#hotmail.com" name="LoginId" id="LoginId" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td>
<b>Date/Time Added</b>
</td>
<td>
<input type="text" value="12/19/2012 12:00:00 AM" name="CreationDate" id="CreationDate" disabled="disabled" class="textarea wide">
</td>
</tr>
<tr>
<td>
<b>Call Status</b>
</td>
<td>
<input type="text" value="Completed" name="CallStatus" id="CallStatus" disabled="disabled" class="textarea normal">
</td>
</tr>
<tr>
<td>
<b>Archived</b>
</td>
<td>
<input type="checkbox" value="true" name="isArchived" id="isArchived" disabled="disabled"><input type="hidden" value="false" name="isArchived">
</td>
</tr>
</tbody></table>
</td>
[Edit2]
Request URL:http://localhost:62843/recording/UpdateRecordingDetails
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/json
Cookie:SiteBrowsedCookie=1;edited value&FirstVisit=9/14/2012 5:42:08 PM; Nop.customer=61f1bf57-034a-4427-a08c-e9442061f224; glimpseState=null; glimpseClientName=null; glimpseOptions=null; ASP.NET_SessionId=lephqzclxx35mjqier5to5l4; .CRM=85A97958C0415B3C8106A7EE2B473EE00C1F53C5E428C399AC951D7AFEA5A325C8BC54225AC959917CF1754734CF8DC6BD13DAAA7DA1EE64D4A177BB3FA3529992A1E596AF6D1D4391242C412EB809F8125EC03DBC1C5A36FDAE3BAB915E2233C30E0876EFE62B3D8CAE1CCAD020DA6791EA17FD3B085C1A913C8DBF822408FD0E2AA3B19F67AFE34C9176A3783F0935D61B847D51958ABB72AB2E9491864F956A90729E; returnUrl=returnUrl=http://localhost:62843/Account/Login
Host:localhost:62843
Origin:http://localhost:62843
Referer:http://localhost:62843/Recording/Detail
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
X-Requested-With:XMLHttpRequest
Response Headersview source
Cache-Control:private, s-maxage=0
Connection:Close
Content-Length:8
Content-Type:text/html; charset=utf-8
Date:Fri, 21 Dec 2012 07:16:02 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
Please suggest solution to it.
data: $('frmRecordingEdit').serialize(),
should be:
data: $('#frmRecordingEdit').serialize(),
because that's how id selectors work in jQuery.
Also you haven't shown how/where you are calling the editAccountDetails function that is sending the AJAX request but if this is inside an onsubmit handler of the form or an onclick handler of a submit button of this form or an onclick handler of some anchor you should make sure that you return false from this handler to ensure that you are cancelling the default action and giving chance of the AJAX call to execute. If you do not cancel the default action the browser will simply redirect away from the page leaving no chance of any AJAX calls to execute.

Resources