ボタンでリダイレクトしたときに引数を渡すにはどうすればよいですか:
- メソッド afficher を呼び出すとき、引数が必要です。どうすれば追加できますか
- afficher() の引数のようにエディターフィールドの値を渡すにはどうすればよいですか
ファイル:Index.cshtml
<body onload="initialize()">
<div id="map_canvas" style="width: 800px; height: 500px;"></div>
@using (Html.BeginForm("Afficher", "Historique"))
{
<div>
<fieldset>
<legend>Tracking Information</legend>
<div class="editor-label">
<label title= "jour " runat="server" > day of begin </label>
</div>
<div class="editor-field">
<input id="day_begin" name= "day_begin" />
</div>
<div class="editor-label">
<label title= " heure " runat="server" > hour of begin </label>
</div>
<div class="editor-field">
<input id="hour_begin" name= "hour_begin" />
</div>
<div class="editor-label">
<label title= " minute " runat="server" > minute of begin </label>
</div>
<div class="editor-field">
<input id="minute_begin" name= "minute_begin" />
</div>
<div class="editor-label">
<label title= " jour " runat="server" > day of end </label>
</div>
<div class="editor-field">
<input id="day_end" name= "day_end" />
</div>
<div class="editor-label">
<label title= " heure " runat="server" > hour of end </label>
</div>
<div class="editor-field">
<input id="hour_end" name= "hour_end" />
</div>
<div class="editor-label">
<label title= " minute " runat="server" > minute of end </label>
</div>
<div class="editor-field">
<input id="minute_end" name= "minute_end" />
</div>
<p>
<input type="submit" value="Done" runat="server" />
</p>
</fieldset>
</div>
}
@using (Html.BeginForm())
{
<div>
<fieldset>
<legend>Result</legend>
<table id ="table 1" runat="server" ></table>
</div>
}
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Lay2.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var myLatLng = new google.maps.LatLng(36.802584, 10.108191);
var myOptions = {
zoom: 30,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var flightPlanCoordinates = [
new google.maps.LatLng(36.802584, 10.108191),
new google.maps.LatLng(36.801897, 10.102955),
new google.maps.LatLng(36.802275, 10.110788),
new google.maps.LatLng(36.805024, 10.109049)
];
var flightmarker = new google.maps.Marker({
position: new google.maps.LatLng(36.802584, 10.108191),
map: map,
title: " denden"
});
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
</script>
</body>
ファイル HistoriqueController.cs:
public ActionResult Afficher(int b1,int b2, int b3, int e1, int e2, int e3)
{
double d1 = b1 * 10000 + b2 * 100 + b3;
double d2 = e1 * 10000 + e2 * 100 + e3;
ViewBag.Title = (d2 - d1).ToString();
Parcours p = new Parcours(d1, d2);
var model = p._segments;
return View(model);
}
エラーがあります:
The parameters dictionary contains a null entry for parameter 'b1' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Afficher(Int32, Int32, Int32, Int32, Int32, Int32)' in 'MvcApplication7.Controllers.HistoriqueController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Nom du paramètre : parameters