I have below piece of code. Whenever I click on upload button, the file submits. If there is an error, then it will be displayed in the grid. But, when I click on A page number, then the controller action, "Upload," gets called with the page number as the input. Also, when I click on the column name for sorting, then the controller action "Upload" gets called with sort=columnname and sortDIR=ASC parameters.
I want to prevent these controller action calls.
In Controller:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase fileUpload)
{
}
In Design:
@using (Html.BeginForm("Upload", "FileUpload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="fileUpload" size="35" id="fileupload"/>
<br />
<br />
<span class="button">
<input type="submit" class="form_button" value="Upload" id="btnUpload" />
</span>
<span class="button">
<input type="reset" id="btnCancel" value="Cancel" name="Cancelbutton" class="form_button" />
</span>
<div id="progressbardiv" style="display:none; font-size:medium;">
<img src="../../Images2/ajax-loader.gif"/>Uploading File...
</div>
<br />
<br />
}
@if (Model.lstError != null)
{
<div id="grid">
@{
var grid = new WebGrid(source: Model.lstError,
canSort: true,
rowsPerPage: 10
);
}
@grid.GetHtml(
tableStyle: "webGrid",
headerStyle: "gridHead",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("RowId", header: "Sr.No"),
grid.Column("EmployeeID", header: "Emp Id"),
grid.Column("ApplicantID", header: "Candidate Id"),
grid.Column("EmployeeName", header: "Employee Name"),
grid.Column("Message", header: "Message")
)
)
</div>
}