@Html.ActionLink((string)Model[i]["name"], "Info", "Home", new { uid = Model[i]["uid"].ToString() }, null)
[HttpGet]
public ActionResult Info(string uid)
{
TempData["uid"] = uid;
SearchModel model = new SearchModel();
List<DataTable> tables = model.GetUserInfo(uid);
TempData["tables"] = tables;
return View(model);
}
In the controller, there is a method that returns JsonResult. This method is used to obtain data, on the basis of which the js code will be executed.
public JsonResult GetCountryRisk(SearchModel model)
{
string uid = TempData["uid"].ToString();
IEnumerable<CountryRisk> list = new List<CountryRisk>();
list = model.GetCountryRisk(uid);
TempData["uid"] = uid;
return Json(list, JsonRequestBehavior.AllowGet);
}
The view has elements that simulate tabs and when clicked on the selected item, Ajax is called, which receives the data and passes it to the script.
<div id="tabHeadDiv">
<input type="button" value="Summary" class="tabControl" id="1" onclick="ShowOrHideTabs(this.id)" />
@Ajax.ActionLink("Relations", "Info", null, new AjaxOptions { Url = Url.Action("GetDataForGraph"), OnSuccess = "DrawGraph" }, new { @id = "2", @class = "tabControl" })
@Ajax.ActionLink("Map", "Info", null, new AjaxOptions { Url = Url.Action("GetCountryRisk"), OnSuccess = "drawRegionsMap" }, new { @id = "3", @class = "tabControl" })
</div>
Problem is that if a user opens several links in a new tab and wants to go to the tab, then on all tabs the result will be displayed, which was executed last.
So I want to understand if it's possible to send parameter to the GetCountryRisk method without using TempData ["uid"].
uida part of the search model and pass it as a param in links@Ajax.ActionLink("Map", "Info", new { tUid = ViewBag.Main.Rows[0]["uid"]}, new AjaxOptions { Url = Url.Action("GetCountryRisk"), OnSuccess = "drawRegionsMap" }, new { @id = "3", @class = "tabControl" })but in controllers it returnnull.