私は3つのファイルアップロードと3つのラジオボタンが関連付けられています。
すべてのラジオボタンは、相互排他的にするために同じ名前が付けられています。ASP.NET MVCのFileUploadに対応するCheckBox値を取得
<div>
Upload Files:<br />
<p>
<input type="file" name="resim1" id="resim1" />
<%= Html.RadioButton("defaultresim", "", true, new { id = "defaultresim1" })%><label for="defaultresim1">Set as default</label>
</p>
<p>
<input type="file" name="resim2" id="resim2" />
<%= Html.RadioButton("defaultresim", "", true, new { id = "defaultresim2" })%><label for="defaultresim2">Set as default</label>
</p>
<p>
<input type="file" name="resim3" id="resim3" />
<%= Html.RadioButton("defaultresim", "", true, new { id = "defaultresim3" })%><label for="defaultresim3">Set as default</label>
</p>
</div>
Viewは、私はこのような私のコントローラロジックを持っています。
List<ProductImage> images = new List<ProductImage>();
if (collection != null)
{
for (int i = 0; i < collection.Count; i++)
{
HttpPostedFileBase resim = collection[i];
if (resim != null)
{
ProductImage image = new ProductImage();
byte[] temp = new byte[resim.ContentLength];
resim.InputStream.Read(temp, 0, resim.ContentLength);
image.ImageData = temp;
image.ImageMimeType = resim.ContentType;
// How to get the image that will be marked as default?
//image.IsImageDefault = ??;
images.Add(image);
}
}
}
ここで私のコードスニペットはブラウザのように見えます。
私は、ループ内で、理想的image.IsImageDefault
値を取得したいと思います。
私はMVCをかなり新しくしていますが、まだWebFormsにハングアップしています。
このような状況を解決するには何が必要ですか?
あなたがショーすることができます私はそれを得る方法について1つのライナーですか? – naveen
完全なアクションメソッド(または少なくともそのシグネチャ)の上に含めることができるので、どのパラメータがそれに渡されているのかわかりますか? – patmortech
簡単な例として私の編集を見てください。 – patmortech