Reputation: 316
Giving the user the option to see the rows returned from the search or not. If I hit Cancel, it still runs the controller code.
HTML:
<td><input type="submit" name="SubmitSearch" id="search" value="Search" class="form-control alert-success" onclick="return rowcount()" /></td>
Javascript:
<script type="text/javascript">
function rowcount() {
confirm("There are rows");
}
Controller:
[HttpPost]
public ActionResult OracleVerification(string company, string location, string product, string department)
{
List<OracleStringViewModel> oracleStringList = OracleStringRepository.GetOracleStrings(company, location, product, department);
return View(oracleStringList.ToList());
}
Upvotes: 0
Views: 76
Reputation: 167172
The construct confirm()
returns true
or false
. You need to make use of it. You forgot to use the return
keyword:
function rowcount() {
return confirm("There are rows");
}
The problem here is, the confirm
actually return
s the boolean value from the user, but it goes nowhere. You need to return
it back to the calling place, which is the input
's onclick
event.
Upvotes: 1