Reputation: 2339
Having a issue with windows.open();
When the function trigger it should send parameters to the controller
firstname
, lastname
, dob
, and gender
but I am having an issue it just sending firstname
and other parameters are null. when i debug it on the client side it is showing all parameters have values but when it calls action result it just sending one parameter.
$(document).ready(function() {
$(".ViewGet").click(function () {
var firstname = $(this).closest("tr").find(".firstname").text();
var lastname = $(this).closest("tr").find(".lastname").text();
var dob = $(this).closest("tr").find(".dob").text();
var gender = $(this).closest("tr").find(".gender").text();
window.open('@Url.Action("FindClientsFor","ClientSerach")?lastname=' + firstname, "&" + +"firstname=" + lastname + "&dob=" + dob + "&gender=" + 1 + 'popUpWindow', 'height=750, width=960, left=300, top=100, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes');
});
});
Controller
[HttpGet]
public ActionResult FindClients(string firstname, string lastname, string dob, int? gender,FormCollection collection)
{
if (IsNullOrEmpty(firstname) || IsNullOrEmpty(lastname) || IsNullOrEmpty(dob) || gender == null)
{
return RedirectToAction("Index");
}
else
{
var obj = _repo.ClientSearchWithAll(firstname, lastname, dob, gender);
//_repo.SortUserNames(obj);
return View(obj);
}
}
Upvotes: 0
Views: 45
Reputation: 16675
Your window.open
parameters have major concatenation issues.
You used + +
and firstname, "&"
which breaks the concatenation, and forgot to pass a comma (,
) before the window.open
2nd and 3rd arguments.
You also mixed the firstname
and the lastname
variables.
Try this:
window.open('@Url.Action("FindClientsFor","ClientSerach")?lastname=' + lastname + '&firstname=' + firstname+ '&dob=' + dob + '&gender=1', 'popUpWindow', 'height=750, width=960, left=300, top=100, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes');
Upvotes: 1