hi I’m creating a project where the user all the user are running off the same instance using the singleton design pattern. when user types a value into a textbox. It will then wait until everyone else has type a value and then display the results. My question is can this be done using buttons that send a value to the model instead of a textbox. e.g. multiple buttons each one sending a different value.
Heres my code now.
view
@{
ViewBag.Title = "Voting";
}
@using (Html.BeginForm())
{
<fieldset>
<div class="editor-label">
What is you vote?
</div>
<div class="editor-field">
@Html.TextBox("Vote")
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
controller
public ActionResult PlanVote()
{
return View();
}
[HttpPost]
public ActionResult PlanVote(int vote)
{
PlanModel myModel = PlanModel.Instance;
myModel.Vote(vote);
if (PlanModel.Instance.currentstate == PlanState.displaying)
{
return RedirectToAction("Index", "Plan");
}
else
{
return RedirectToAction("Waiting", "Plan");
}
}
model
public void Vote(int Votes)
{
countVotes++;
ivote.Add(Votes);
if (countVotes >= iCount)
{
currentstate = PlanState.displaying;
}
}
I’m still Quite new to MVC and would be great-full for any help thanks
Just remove stand alone submit button and use one submit per vote