How to implement Survey page using ASP.NET MVC?
Posted
by
Aleks
on Stack Overflow
See other posts from Stack Overflow
or by Aleks
Published on 2012-12-16T22:45:30Z
Indexed on
2012/12/16
23:03 UTC
Read the original article
Hit count: 507
I need to implement the survey page using ASP.NET MVC (v.4)
That functionality has already been implemented in our project using ASP.NET WebForms.
(I really searched a lot for real examples of similar functionality implemented via MVC, but failed)
Goal: staying on the same page (in webforms -'Survey.aspx') each time user clicks 'Next Page', load next bunch of questions (controls) which user is going to answer. Type of controls in questions are defined only in run-time (retrieved from Data Base).
To explain better the question I manually created (rather simple) mark-up below of 'two' pages (two loads of controls):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Survey.aspx.cs" Inherits="WebSite.Survey" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><h2>Internal Survey</h2></div>
<div><h3>Page 1</h3></div>
<div style="padding-bottom: 10px"><div><b>Did you have internet disconnections during last week?</b></div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
</div>
<div style="padding-bottom: 10px"><div><b>Which days of the week suit you best for meeting up ?</b></div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
</asp:CheckBoxList>
</div>
<div style="padding-bottom: 10px">
<div><b>How satisfied are you with your job? </b></div>
<asp:RadioButtonList ID="RadioButtonList2" runat="server">
<asp:ListItem>Very Good</asp:ListItem>
<asp:ListItem>Good</asp:ListItem>
<asp:ListItem>Bad</asp:ListItem>
<asp:ListItem>Very Bad</asp:ListItem>
</asp:RadioButtonList>
</div>
<div style="padding-bottom: 10px">
<div><b>How satisfied are you with your direct supervisor ? </b></div>
<asp:RadioButtonList ID="RadioButtonList3" runat="server">
<asp:ListItem>Not Satisfied</asp:ListItem>
<asp:ListItem>Somewhat Satisfied</asp:ListItem>
<asp:ListItem>Neutral</asp:ListItem>
<asp:ListItem>Satisfied</asp:ListItem>
<asp:ListItem>Very Satisfied</asp:ListItem>
</asp:RadioButtonList>
</div>
<div style="padding-bottom: 10px">
<asp:Button ID="Button1" runat="server" Text="Next Page"
onclick="Button1_Click" />
</div>
</form>
</body>
</html>
PAGE 2
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Survey.aspx.cs" Inherits="WebSite.Survey" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><h2>Internal Survey</h2></div>
<div><h3>Page 2</h3></div>
<div style="padding-bottom: 10px"><div><b>Did admininstators fix your internet connection in time ?</b></div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
</div>
<div style="padding-bottom: 10px"><div><b>What's your overal impression about the job ?</b></div>
<asp:TextBox ID="TextBox1" runat="server" Height="88px" Width="322px"></asp:TextBox>
</div>
<div style="padding-bottom: 10px">
<div><b>Select day which best suits you for admin support ? </b></div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select day</asp:ListItem>
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
</asp:DropDownList>
</div>
<div style="padding-bottom: 10px">
<asp:Button ID="Button1" runat="server" Text="Next Page"
onclick="Button1_Click" />
</div>
</form>
</body>
</html>
© Stack Overflow or respective owner