117
rated 0 times
[
122]
[
5]
/ answers: 1 / hits: 17201
/ 11 Years ago, wed, december 4, 2013, 12:00:00
In my ASP.Net project I'm trying to redirect a page to other action after select a row table and click on a button. So I have this code:
JQuery:
function editItem(tableId, url) {
if ($(# + tableId + .selected).exists()) {
var thisRowId = $(# + tableId + .selected).attr(id);
window.location.replace(url, { operation: edit, carId: thisRowId });
}
};
//more code
View (ManagementCar):
@model myProject.Model.Car.Car[]
<table class=table id=tableCars>
<thead>
@*some code to header*@
</thead>
<tbody>
foreach (var item in Model)
{
<tr id=@(item.Id) onclick=selectRow('tableCars', '@(item.Id)')>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.OwnerName)
</td>
<td>
@(item.IsSold == true ? Yes : No)
</td>
</tr>
}
</tbody>
</table>
<br />
<button id=btEdit type=button class=disable onclick=editItem('tableCars','CarOperation')>Edit</button>
Controller:
[HttpGet]
public ActionResult CarOperation(string operation, int carId)
{
//some code...
return RedirectToAction(ManagementCar, Backoffice);
}
But I have a Server Error after redirect saying carId
parameter is null. I debug my jquery and that parameter isn't null. I tried also doing
$.get(url, { operation: edit, carId: thisRowId });
instead
window.location.replace(url, { operation: edit, carId: thisRowId });
but it don't redirect.
How can I solve this?
More From » jquery