In View-
<input type="text" hidden="hidden" id= "nameString" name="nameString" value="xyz" />
@Html.ActionLink("Save", "HomePage", "ControllerName", new { nameString = "/* Value from above input here.*/" })
In this case I want to pass "xyz" through this hyperlink.
Can't use Get or POST methods to pass this value.
This HomePage view is not the current ActionLink view either, so can't grab the value in Controller using Request.Form["nameString"];
I tried JQuery like following but its not working-
var nameVar = document.getElementById('nameString').value;
$.ajax({
type: 'GET',
url: "@Url.Action("HomePage", "ControllerName")",
data: { nameString : nameVar }
});
I checked in debugger and saw that Controller is actually getting value and processing it but nothing is coming on browser. I am not sure how ajax works.