I have something like this:
public ActionResult ImageReplace(int imgid,HttpPostedFileBase file)
{
string keyword = imgid.ToString();
.
You can also pass imgid
as a field in the form, something like:
@model Models.MemberData
@using (Html.BeginForm("ImageReplace", "Member", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
@Html.HiddenFor(x => x.Id)
<input type="file" name="file" id="file" value="Choose Photo" />
<input type="submit" name="submit" value="Submit" />
}
Use this overload, which allows you to distinguish between route values and HTML attribtues:
@using (Html.BeginForm(
"ImageReplace", "Member",
new { imgid = @Model.Id },
FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" id="file" value="Choose Photo" />
<input type="submit" name="submit" value="Submit" />
}
Use this:
@using (Html.BeginForm("ImageReplace", "Member",
new { imgid = @Model.Id }, FormMethod.Post,
new { enctype = "multipart/form-data" }))
@using (Html.BeginForm("Search", "Orders", FormMethod.Post, htmlAttributes: new { id = "example-form", @class = "app-search" }))
{
<input type="text" class="form-control" name="OrderNo" style="max-width:100% !important" placeholder="Search OrderNo">
<a class="srh-btn">
<i class="ti-close"></i>
</a>
</input>
}
public ActionResult Search(FormCollection form)
{
string Orderno = form["OrderNo"];
int orderno = Convert.ToInt32(Orderno);
return View(orderno );
}