2017-08-31 4 views
0

)を経由してすべての値を送信しないjQueryの経由で新しいブラウザウィンドウを開きます。はwindows.open(との問題を持つパラメータ

  • フレームワーク:Asp.netMVC
  • コード:C位、カミソリ
  • 問題:機能トリガは、それがコントローラにパラメータを送信する必要があるとき

jqueryの firstnamelastnamedob、及びgenderが、私はそれだけでfirstnameを送信し、他のパラメータがNULLの問題を抱えています。私はクライアント側でそれをデバッグするときには、すべてのパラメータが値を持っているが、それはそれだけで一つのパラメータを送信するアクションの結果を呼び出したときに表示されます。

$(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'); 

    }); 
}); 

コントローラ

[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); 
    } 
} 

答えて

1

あなたwindow.openパラメータは、主要な連結の問題を持っています。

あなたは+ +と連結を壊すfirstname, "&"を使用し、window.open 2番目と3番目の引数の前にカンマ(,)を渡すのを忘れていました。

またfirstnameを混合し、lastname変数。

これを試してみてください:

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');