I have a 40 question survey that I need to take the answers from and do a bit of analysis on. Based on the survey results, custom content will be generated. My question is, how do I get the aspx page the survey is posted to, to retrieve all of the question variables so I can work with them? Since the survey is rather long, doing it all as a query string is not a real solution.
I know in PHP I could do it as $someVar = $_POST["$surveyAnswer"]; I just can't find a simple equivalent in ASP.NET just yet.
Any help is appreciated,
-MikeWell, what format are you displaying them in? When the page posts back, you can simply access them by referencing their control ID. Keep in mind ASP.NET posts back to the same page.
Brian
The survey answers are radio buttons with numeric values. I want to take those answers and do some math on them (each question belongs to a category, I want to generate an average score per category). Based on those category scores, I have a stack of content that I then want to display based on what numbers come out. All formatted as a web page.
I don't want to have all of this done and displayed on the same page as the survey is pretty darn long, and the resulting page will be even longer. How can I do this?
I've been digging around all morning and the closest to an answer I can figure is to have it post back to itself, do the number analysis in a button-click event, then redirect to a second page using a querystring with the category scores, unfortunately I don't know quite how to actually do that either.
-Mike
Hi Mike,
Can you post your html code for the aspx page? You need to write the code for number analysis inside Button_Click event so that It will run when the button is clicked. And to redirect to a new page you can use either Response.Redirect() or Server.Transfer() methods.
And you can reference the answers using FindControl("id") method.
Thanks,
Sridhar!!
Here's the form I've built as an example. I need to have the answer options separated out between table cells.
<form runat="server">
<table width="100%" border="0">
<tbody>
<tr>
<td> Question 1 </td>
<td> <input type="radio" name="q1" value="1" runat="server">Opt 1 </td>
<td><input type="radio" name="q1" value="2" runat="server">Opt 2 </td>
</tr>
<tr>
<td></td>
<td></td>
<td> <input onclick="Button_Click" type="submit" value="Submit" name="Submit" runat="server" /></td>
</tr>
</tbody>
</table>
</form>
I've tried using <asp:RadioButtonList> but it doesn't let me separate out the button items into table cells since it doesn't like having HTML tags inbetween. I've tried to use the FindControl("id") method to just redisplay the submitted answers, but no dice on that.
-Mike
Actually a RadioButtonList generates an HTML table for rendering the output anyway, as specified by the RepeatLayout property RepeatDirection and RepeatColumns properties determine the flow of the repeated items.
Brian
No comments:
Post a Comment