This project is read-only.

Dynamically change results file

Jul 25, 2007 at 8:46 AM
Edited Jul 25, 2007 at 8:48 AM
Hi. I have made a user control (.ascx file) which inserts either the WebSurvey or the SurveyResult control depending on whether the survey has been taken. I want to pass in the name of the survey which then sets the questions and answers file names. This works with the WebSurvey control but not the SurveyResult. Is it possible to set the SurveyResult properties dynamically? Here is my code: -

<%@ Control Language="VB" ClassName="Poll" %>
<%@ Register TagPrefix = "sstchur" Namespace = "sstchur.web.survey" Assembly = "sstchur.web.survey" %>

<script runat = "server">

Public SurveyName as String = ""
protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

'This will programatically update all the references
ws.SurveyFile = "applications/polling/" + SurveyName + "Q.xml"
ws.AnswersFile = "applications/polling/" + SurveyName + "A.xml"
sr.SurveyFile = "applications/polling/" + SurveyName + "Q.xml"
sr.AnswersFile = "applications/polling/" + SurveyName + "A.xml"

End Sub

'Determine if the survey has already been taken
if (ws.PreviouslyCompleted)
pnlSurvey.Visible = false
pnlThankYou.Visible = true
end if

<div class="poll">
<h3>Quick Poll</h3>
<asp:Panel id = "pnlSurvey" Visible = "true" runat = "server">
<form id="Form1" runat = "server">
<sstchur:WebSurvey id = "ws" runat = "server"/>

<asp:Panel id = "pnlThankYou" Visible = "false" runat = "server">
<form id="Form2" runat = "server">
<p>Thank you for participating in our survey.</p>
<sstchur:SurveyResult id = "sr"
SurveyFile = "applications/polling/surveySample.xml"
AnswersFile = "applications/polling/answersSample.xml"
Stylesheet = "applications/polling/stylesheet.xsl"
XQuery1 = "//WebSurvey/Group/Question"
XQuery2 = "//Answers/AnswerSet/Answer"
runat = "server"/>

The problem is the result panel always shows the answers in the applications/polling/answersSample.xml file and does not get changed to the new file name. I guess it is probably a problem with the order of code execution, but I'm an newbie so please be kind!!

Many thanks for any help!
Aug 24, 2007 at 4:12 PM
Ah, yes. There were numerous problems with setting the SurveyFile programatically which did get fixed, but (evidentally) the fixes were never ported to the SurveyResult.

I will try to look into this soon.

Sep 26, 2007 at 2:12 AM

sstchur wrote:
Ah, yes. There were numerous problems with setting the SurveyFile programatically which did get fixed, but (evidentally) the fixes were never ported to the SurveyResult.

I will try to look into this soon.


Hi Steve,

I was wondering when you expected that the changes to SurveyResult in respect to programatically changing the options within <sstchur: SurveyResult /> would be fixed.

I have been stuggling to get this working in the same was a WebSurvey (ie programiatically) and upon searching the web I have come across this post which appears to answer my question.

Oct 2, 2007 at 5:52 PM

I think this issue should be cleared up in the most recent codebase. If you download the latest source code, I've included a TestHarness project in which I demonstrate how to set the .SurveyFile and/or the .AnswersFile in the Page_Load method.

See if that helps,
Oct 2, 2007 at 5:54 PM
Oh shoot! My bad guys. I was thinking you wanted the ability to change .SurveyFile/.AnswersFile -- but you were asking about SurveyResult, which I haven't worked on much lately.

I can try to look into this, but (as I'm sure you all can tell, my free time to do this stuff is limited).

Anyone interested in trying to tackle this issue and offering back your modifications to the project?

Oct 25, 2007 at 8:10 PM
Hi Steve,

I presume you haven't had any chance to look at this yet.

Sorry to sound pushy, but do you have any idea when you may get chance to look.

I have used Websurvey in a project I have been working on. I left the survey results to the end and then came across this issue. Without SurveyResult being able to be programatically set the file locations, all the work I have currently done is wasted and I will have to look into using something else, as I need to deliver the project in the next couple of weeks.

If I had the knowledge I would certainly volenteer to assist in this, but unfortunately I dont.

Kind regards
Nov 5, 2007 at 6:24 AM
I'm sorry; I have not yet had a chance to look into this.

I will try to do it soon, but no guarantees.

Nov 12, 2007 at 5:06 AM
Firstly - fantastic control.

Secondly - a possible solution to this issue (and excuse me if terminology isn't quite right).

A quick way to fix this issue would be to provide a contructor for the control, with the ability to provide the properties in the construct:

public SurveyResult(surveyfilename, answerfilename, stylesheet, xquery1, xquery2)

Use these to set the values during intialisation.

That way in code, we could call:

Dim tmpsurvey As SurveyResult = New SurveyResult (surveyfilename, answerfilename, stylesheet, xquery1, xquery2)

anytime we wanted to change values, we could just dynamically create a control, and sett he value of the control on the page to that of the temp one created.

This might work - not sure - not done too much with this type of programming ina long long long long time.
Nov 13, 2007 at 6:41 PM
Alright, I have delayed on this long enough. I will try to take a look today.

I appreciate everyone's enthusiasm with this control. I honestly never expected it to gain anywhere near as much excitement as it has. I've been focusing most of my efforts on my (Javascript library) which hasn't gotten anywhere /near/ as much attention :-P

If only I had more time to work on WebSurvey these days....
Nov 13, 2007 at 7:01 PM
Ok, I made a real quick attempt to implement this feature (actually it was a timing issue, so there wasn't much to implement, but hopefully this will do the trick).

Source is available form the Source Tab and the DLL is available under the Releases section.