我要打印用户选择的复选框的值。
View.cshtml
<input type="checkbox" id="vehicle1" name="checkResp" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="checkResp" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="checkResp" value="Boat">
<label for="vehicle3"> I have a boat</label><br><br>
控制器
public ViewResult Form(string receiveremail, string subject, string message,string name, int qty, string[] checkResp)
{
Body = "Dear " + name +" Your Order have been successfully Placed. Number of products placed are " + qty + "from " + qty + " Store" + checkResp;
}
请任何人能帮助您
如果要同时添加两个产品,请使用String.Join(delimiter,array)
;
Body = "Dear " + name +" Your Order have been successfully Placed. Number of products placed are " + qty + "from " + qty + " Store" + String.Join(",",checkResp);
如果您要使用单个项目,请使用array[index]
;
Body = "Dear " + name +" Your Order have been successfully Placed. Number of products placed are " + qty + "from " + qty + " Store" + checkResp[0];