2016-08-19 4 views
0

私はMVCを勉強しており、これに固執しています。名前、カテゴリ、タイプ、最小値、最大値のフィルタを作成しようとしていましたが、別のビューにリダイレクトされたときに3つのパラメータしか表示されず、他の値は表示されません。mvc4の複数のパラメータ

コントローラ(DetailController)

public ActionResult FilteredResult(string searchedLocation, string Type, string PCName, string MinValue, string MaxValue) 
{ 
    var A = searchedLocation; 
    var B = Type; 
    var C = PCName; 
    var D = MinValue; 
    var E = MaxValue; 
    return View(); 
} 

ビューは

@using (Html.BeginForm("FilteredResult", "Detail", FormMethod.Get)) 
{ 
    <form> 
     <h4 style="color: #ed145b;">Find the right property for you</h4> 
     <ul class="form-style-1"> 
      <li> 
       @Html.TextBox("Location", ViewBag.Location as string , new { @class = "field-long" }) 
      </li> 
      <li> 
       @Html.DropDownList("Type", (SelectList)ViewBag.TypeList, "Select" , new { @class = "field-select" }) 
      </li> 
      <li> 
       @Html.DropDownList("Category", (SelectList)ViewBag.CategoryList, "Select" ,new { @class = "field-select" }) 
      </li> 
      <li> 
       <label for="amount">Price range:</label> 
       <input type="text" id="amount" class="field-long" readonly style="border:0; color:#ee2265; font-weight:bold;"> 
      </li> 
      <li class="clearfix"> @Html.TextBox("MinValue", ViewBag.MinValue as string, new { @class = "Minprice field-long", disabled = "true" }) 
       @Html.TextBox("MaxValue", ViewBag.MaxValue as string, new { @class = "Maxprice field-long", disabled = "true" }) 
      </li> 
      <li> 
       <div id="slider-range"></div> 
      </li> 
      <li> 
       <input type="submit" value="Search" class="btn-primary" /> 
      </li> 
     </ul> 
    </form> 
} 

enter image description here

検索をクリックした後、それはこのように表示されます。ドロップダウンからのデータのみが表示され、最小値や最大値などの他のパラメータはURLに表示されません。場所は

enter image description here

を示していることは誰もが、私は成功し、コントローラに必要なフィールドにデータを取得することができますどのように私を助けることができますか?

+0

( '; するvar B =タイプ; するvar C = PCName;'のvar A = searchedLocationを するvar D = MinValueプロパティ; VAR E = MaxValueを)? Viewにデータを渡すことはありません。 –

+0

'http:// localhost:1044/Detail/FilteredResult?Location = asdf&Type = 2&Category = 1&MinValue = 12&MaxValue = 323421215' – Avinash

+0

最初にすべきことは、このプロパティを内部に配置することです。モデルを作成してコードを整理して簡単にバインドします – Sherlock

答えて

2

あなたのMinValueとMaxValueのテキストボックスにはdisabled="true"という属性があるからです。障害者の入力はあなたがそれらのテキストボックスが編集不可にしたい場合は、あなたのため、代わりに

@Html.TextBox("MinValue", ViewBag.MinValue as string, new { @class = "Minprice field-long", @readonly = "readonly" }) 
@Html.TextBox("MaxValue", ViewBag.MaxValue as string, new { @class = "Maxprice field-long", @readonly = "readonly" }) 
0

readonly属性を使用disabled属性

@Html.TextBox("MinValue", ViewBag.MinValue as string, new { @class = "Minprice field-long" }) 
@Html.TextBox("MaxValue", ViewBag.MaxValue as string, new { @class = "Maxprice field-long" }) 

を削除する必要があります

@Html.TextBox("MinValue", ViewBag.MinValue as string, new { @class = "Minprice field-long", disabled = "true" }) 
@Html.TextBox("MaxValue", ViewBag.MaxValue as string, new { @class = "Maxprice field-long", disabled = "true" }) 

を提出されることはありませんdisabled属性trueを使用しています。つまり、データベースからデータをフェッチしますが、Viewには表示されません。したがって、disabled = "false"を設定するか、この属性を削除してください。 FilteredResultであなたが宣言された変数を使用したいどうすればよい

関連する問題