I have a cshtml file and a button that on click calls a javascript method.
@using (Html.BeginForm("PlayGameRound", "Games", new { id = Model.GameId,
category = Model.Category }))
{
@Html.AntiForgeryToken()
<div class="form-group">
<input type="submit" value="Play" style="float: left" id="play" onclick="@Model.Category = play()"/>
</div>
}
This is the javascript file method that is called.
function play() {
if (hideSpin) {
return category;
}
}
When i am running my program the javascript method is never called. How would I ensure the method is called when the button is clicked?
onclick="play(). But you cannot assign it to a model property (razor is server side code)hideSpin? What iscategory? What is it that you want to post back to the controller and bind to you model?