So I have the MVC stuff for the poll creation, they each have a unique id, but I don't know how to display the list of polls on the main page, which should increase with each poll created, and how to get each view to display a different poll. I have all of the poll objects in a List, but how do I set up my controller such that when each different link is clicked, the user goes to the appropriate view id which automatically displays the right poll? And what view should I make in that context?
In my controller I have
public ViewResult ViewPoll(string id)
{
return View(id);
}
And in my main page view
<%
foreach (var poll in Poll.Models.PollsRepository.Get().polls)
{ %>
<p><%= Html.ActionLink("Poll Number", "ViewPoll", new { id = poll })%> is open </p>
<% }
%>
</div>
Which throws this error when I click on them:
The view 'Poll.Models.PollModel' or its master was not found. The following locations were searched:
~/Views/Home/Poll.Models.PollModel.aspx
~/Views/Home/Poll.Models.PollModel.ascx
~/Views/Shared/Poll.Models.PollModel.aspx
~/Views/Shared/Poll.Models.PollModel.ascx
But did I not specifically tell the controller to go to the ViewPoll action in the links? Why is it still not searching there, and what am I missing?
Thanks!!!
Edited by Alyn, 30 October 2011 - 03:30 AM.
added code tag


Sign In
Create Account

Back to top









