I want pass value to ActionResult but Dont want to use Querystring and session because value type is guid so dont want to display in URL.
function ViewDetail(ele) {
var Id = $(ele).attr("OrderID");
@TempData["OrderID"] = Id;
}
I want pass value to ActionResult but Dont want to use Querystring and session because value type is guid so dont want to display in URL.
function ViewDetail(ele) {
var Id = $(ele).attr("OrderID");
@TempData["OrderID"] = Id;
}
Basically you can't this way , you are trying to assign server side object to client side data.
However you can do that using Ajax if you write an Ajax action that will assign the data to the tempdata and call that action from the client side by Ajax
Ajax code:
function ViewDetail(ele) {
var Id = $(ele).attr("OrderID");
$.ajax({
type: "POST",
cache: false,
async: false,
url: '@Url.Action("actionname", "controllername")',
dataType: "json",
data: { Id: Id },
failure: function (jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
}
Hope it helps!