DotNetNuke can be an overwhelming beast for people who are new to ASP.Net. It has grown significantly since it's modest beginnings and has graduated from a learning tool to an extremely flexible platform enabling non-technical people to manage web content. Because of the complexity it can be daunting to undertake the task of creating a module from scratch. I recently found the desire to create a survey and looked at the DNN survey module. The some of the questions I wanted to ask could not be answered with a simple radio or check box answer. The questions really needed free-form answer options. Looking deeper at the survey module, I discovered how to add free-form responses to the survey architecture by adding 3 code snippets in the presentation tier, leaving the business and data tiers alone.
Start by adding an item in the combo box for cboOptionType as follows:
cboOptionType<asp:ListItem Value="T">Sort Answer</asp:ListItem>
The remainder of the changes occur in the Survey webform. In the Survey.aspx, add an asp:TextBox to the Item template is in the code in blue in the following snippet:
SURVEY.ASPX <asp:checkboxlist id=chkOptions repeatdirection="Vertical" datavaluefield="SurveyOptionId" datatextfield="OptionName" cssclass="Normal" runat="server" visible="False"></asp:checkboxlist>
<asp:TextBox id=txtAnswer CssClass="Normal" Runat="server" Visible="False"></asp:TextBox>
In the code behind for the Survey Form, add another case statement in the ItemDataBound event handler for lstSurvey as follows:
Dim txtAnswer As TextBox = CType(e.Item.FindControl("txtAnswer"), TextBox)
txtAnswer.Visible = True
One more change remains. To save your user's values, add the following to the SECOND case statement in the cmdSubmit_Click handler:
objSurveyOption.SurveyId = objSurvey.SurveyId
objSurveyOption.OptionName = Request.Form(lstSurvey.UniqueID & ":_ctl" & intQuestion.ToString & ":txtAnswer")
objSurveyOption.ViewOrder = 0
objSurveyOption.Votes = 1
With these simple changes, you now have the ability to add a question with a free-form text box to allow users to enter their information. NOTE: You should always guard against script injection and other vulnerabilities, so additional protections should be taken on what you allow your users to enter in this box. Working through this sample should give you some insight into how the module works and allow you to start making modifications if you have been afraid of module creation in the past.