Welcome to DevAuthority.Com Sign in | Join | Help

Wooley's Wonderings

Insights and observations about VB and .Net technologies. Here we focus on Language Integrated Query (LINQ) which is being featured in the next version of Visual Studio 2008 (formerly known as "Orcas").




<August 2005>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Post Categories

News


MVP Profile
My Books:
LINQ in Action
My BlogMap
Add to Technorati FavoritesMore blogs about linq.

Navigation

Atlanta area bloggers

My Sites

LINQ

Syndication


Extending the DotNetNuke Survey Module

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>
</ITEMTEMPLATE>

In the code behind for the Survey Form, add another case statement in the ItemDataBound event handler for lstSurvey as follows:

lstSurvey_ItenDataBoundCase "T"
     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:

cmdSubmit_ClickCase "T"
     objSurveyOption.SurveyId = objSurvey.SurveyId
     objSurveyOption.OptionName = Request.Form(lstSurvey.UniqueID & ":_ctl" & intQuestion.ToString & ":txtAnswer")
     objSurveyOption.ViewOrder = 0
     objSurveyOption.Votes = 1
     objSurveyOptions.AddSurveyOption(objSurveyOption)

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.

Jim

Published Thursday, August 25, 2005 11:15 PM by jwooley

Comments

# re: Extending the DotNetNuke Survey Module @ Friday, September 22, 2006 11:16 AM

Thanks a lot. It has helped me so much. Unfortunately I'm not good in developing and English as well. Thank you again.

Tania

New Comments to this post are disabled

Powered by Community Server, by Telligent Systems