Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
116 views

Hi,

I need to create a questionnaire in my website. I was using standalone multipage explained here:

http://demos.telerik.com/aspnet-ajax/tabstrip/examples/multipage/standalone-multipage/defaultcs.aspx

I have a set of radio button questions and I use page views to divide them into pages.On the last page I show a​ result graph based on the answers chosen. I need the questions to be required without defaulting a radio button value. Howevere, I am not able to do the validation on a page basis.

Below is the code that I am using.​ Please advise:

<script type="text/javascript">
 
       var minIndex = 0,
           maxIndex = 5,
           globalSelectedIndex,
           multiPage,
           NextPage,
           PreviousPage;
 
       function pageLoad() {
           multiPage = $find("<%= rmRiskTolerance.ClientID %>");
           PreviousPage = $find("<%= PreviousPage.ClientID %>");
           NextPage = $find("<%= NextPage.ClientID %>");
 
           //Initialization of the global selected index of the RadMultiPage control
           globalSelectedIndex = multiPage.get_selectedIndex();
       }
 
       function PrevClicked(sender, args) {
 
           globalSelectedIndex--;
           multiPage.set_selectedIndex(globalSelectedIndex);
 
           if (globalSelectedIndex == minIndex) {
               sender.set_enabled(false);
           }
 
           if (!NextPage.get_enabled()) {
               NextPage.set_enabled(true);
           }
       }
 
       function NextClicked(sender, args) {
           Page_ClientValidate("QuestionnaireValidationGroup");
           if (Page_IsValid) {
 
               globalSelectedIndex++;
               multiPage.set_selectedIndex(globalSelectedIndex);
 
               if (globalSelectedIndex == maxIndex) {
                   sender.set_enabled(false);
               }
 
               if (!PreviousPage.get_enabled()) {
                   PreviousPage.set_enabled(true);
               }
               return true;
           }
           else {
               return false;
           }
 
       }
   </script>
   <div class="page_header">
       <h1>Risk Tolerance Questionnaire</h1>
   </div>
   <div>
       <telerik:RadMultiPage ID="rmRiskTolerance" runat="server" SelectedIndex="0">
           <telerik:RadPageView ID="pvStep1" runat="server">
               
               <h2>Step 1 : Complete the Questionnaire</h2>
               <p>
                   <h4>1. When do you expect to begin distributions from the Plan?
                   </h4>
                   <asp:RequiredFieldValidator ID="rbBeginDistributionRequired" runat="server" ControlToValidate="rbBeginDistribution" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbBeginDistribution" runat="server">
                       <asp:ListItem Text="Within 5 years" Value="2"></asp:ListItem>
                       <asp:ListItem Text="In 5–10 years" Value="4"></asp:ListItem>
                       <asp:ListItem Text="In 5–10 years" Value="8"></asp:ListItem>
                       <asp:ListItem Text="In more than 15 years" Value="12"></asp:ListItem>
                   </asp:RadioButtonList>
               </p>
               <p>
                   <h4>2. Once you begin taking distributions from the Plan, how long do you expect the distributions to last?
                   </h4>
                   <asp:RequiredFieldValidator ID="rbDistributionTimeRequired" runat="server" ControlToValidate="rbDistributionTime" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbDistributionTime" runat="server">
                       <asp:ListItem Text="I plan to take a lump sum distribution" Value="1"></asp:ListItem>
                       <asp:ListItem Text="1 to 5 years" Value="2"></asp:ListItem>
                       <asp:ListItem Text="5 to 10 years" Value="3"></asp:ListItem>
                       <asp:ListItem Text="10 years or more" Value="4"></asp:ListItem>
                   </asp:RadioButtonList>
               </p>
               
           </telerik:RadPageView>
           <telerik:RadPageView ID="pvStep2" runat="server">
 
               <h2>Step 1 : Continued</h2>              
               <p>
                   <h4>3. Investing involves a trade-off between risk and return.  Which statement best describes your investment goals?
                   </h4>
                   <asp:RequiredFieldValidator ID="rbInvestmentGoalsRequired" runat="server" ControlToValidate="rbInvestmentGoals" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbInvestmentGoals" runat="server">
                       <asp:ListItem Text="Protect the value of my account. In order to minimize the chance for loss, I am willing to accept the lower long-term returns provided by conservative investments." Value="1"></asp:ListItem>
                       <asp:ListItem Text="Keep risk to a minimum while trying to achieve slightly higher returns than the returns provided by investments that are more conservative." Value="3"></asp:ListItem>
                       <asp:ListItem Text="Balance moderate levels of risk with moderate levels of returns." Value="6"></asp:ListItem>
                       <asp:ListItem Text="Maximize long-term investment returns. I am willing to accept large and sometimes dramatic fluctuations in the value of my investments." Value="10"></asp:ListItem>
                   </asp:RadioButtonList>
 
               </p>
               <p>
                   <h4>4. Select the portfolio you would be most comfortable investing in:
                   </h4>
                   <asp:RequiredFieldValidator ID="rbPortfolioRequired" runat="server" ControlToValidate="rbPortfolio" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbPortfolio" runat="server">
                       <asp:ListItem Text="Portfolio 1—Annual investment return of 5% or loss of 4%." Value="2"></asp:ListItem>
                       <asp:ListItem Text="Portfolio 1—Annual investment return of 10% or loss of 8%." Value="3"></asp:ListItem>
                       <asp:ListItem Text="Portfolio 1—Annual investment return of 20% or loss of 16%." Value="5"></asp:ListItem>
                       <asp:ListItem Text="Portfolio 1—Annual investment return of 30% or loss of 25%." Value="6"></asp:ListItem>
                   </asp:RadioButtonList>
               </p>
           </telerik:RadPageView>
           <telerik:RadPageView ID="pvStep3" runat="server">
               <h2>Step 1 : Continued</h2>
 
               <p>
                   <h4>5. If the value of your portfolio decreased by more than 20% in one year, how would you react?
                   </h4>
                   <asp:RequiredFieldValidator ID="rbPortfolioDecreaseRequired" runat="server" ControlToValidate="rbPortfolioDecrease" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbPortfolioDecrease" runat="server">
                       <asp:ListItem Text="I would not change my portfolio." Value="11"></asp:ListItem>
                       <asp:ListItem Text="I would wait at least one year before changing to options that are more conservative." Value="8"></asp:ListItem>
                       <asp:ListItem Text="I would wait at least three months before changing to options that are more conservative." Value="3"></asp:ListItem>
                       <asp:ListItem Text="I would immediately change to options that are more conservative." Value="1"></asp:ListItem>
                   </asp:RadioButtonList>
 
               </p>
               <p>
                   <h4>6. If the stock market increased by 15% in one year while the value of your portfolio (invested primarily in bonds and cash) increased by 4% in the same year, how would you react?
                   </h4>
                   <asp:RequiredFieldValidator ID="rbStockMarketIncreaseRequired" runat="server" ControlToValidate="rbStockMarketIncrease" ErrorMessage="* Required" SetFocusOnError="true"
                       ValidationGroup="QuestionnaireValidationGroup"></asp:RequiredFieldValidator>
                   <asp:RadioButtonList ID="rbStockMarketIncrease" runat="server">
                       <asp:ListItem Text="I would replace the bond and cash positions of my portfolio with stocks." Value="10"></asp:ListItem>
                       <asp:ListItem Text="I would add more stocks to my portfolio but not enough to make them a majority position." Value="3"></asp:ListItem>
                       <asp:ListItem Text="I would not change my portfolio." Value="1"></asp:ListItem>
                   </asp:RadioButtonList>
 
               </p>
           </telerik:RadPageView>
           <telerik:RadPageView ID="pvResult" runat="server">
               <h2>Step 2 : Score your Questionnaire</h2>
               <p>
                   Your score is <b>
                       <asp:Literal ID="litScore" runat="server"></asp:Literal></b> and the corresponding M Portfolio Allocation Model is <b>
                           <asp:Literal ID="litAllocationModel" runat="server"></asp:Literal></b>.
               </p>
                   
           </telerik:RadPageView>
       </telerik:RadMultiPage>
       <div class="buttonContainer">
           <telerik:RadButton ID="PreviousPage" Text="Previous" ToolTip="Click to see previous page" runat="server" Enabled="false" AutoPostBack="false" OnClientClicked="PrevClicked">
           </telerik:RadButton>
           <telerik:RadButton ID="NextPage" Text="Next" ToolTip="Click to see next page" runat="server" CausesValidation="true" AutoPostBack="true" OnClientClicked="NextClicked" OnClick="NextPage_Click">
           </telerik:RadButton>
       </div>
   </div>

code behind:

 protected void NextPage_Click(object sender, EventArgs e)
        {
            if (rmRiskTolerance.SelectedPageView.ID == "pvResult")
            {
                List<int> scoreList = new List<int>();
                GetRadioButtonListValues(rmRiskTolerance, scoreList);
                GetQuestionnaireResult(scoreList);
            }
        }​

I could not find any other tool to design a questionnaire. I will be happy to give something else a try if this scenario isn't possible.
Dimitar
Telerik team
 answered on 06 Aug 2015
5 answers
147 views
Hi,

Does chunk upload functionality work on Safari browsers (Safari for Win and Safari for Mac)?
Cannot make it working on Safari(5+) for win7.
I use FileAPI or IFrame plugins. No Flash and Silverlight.

Best regards,
Denis
Geoff
Top achievements
Rank 1
 answered on 06 Aug 2015
3 answers
147 views

Hi 

I am trying to perform the following but am stuck at one point and need some help to move forward - There is a template grid column with a link button that is associated with a custom command. Now on the client click of the link button we want to open up a radwindow to collect user comments & confirm the action.

So on the radwindow close the custom command on that grid row should be fired. How can I get the ​linkbutton that has triggered the radwindow open in the RadWindow Close event and do a post back on that link button for that row to fire the custom command.

 

Any info would be much appreciated.

 

Thanks.

Angel Petrov
Telerik team
 answered on 06 Aug 2015
6 answers
429 views
Hello,

I've got a problem with filtering multiple columns in a RadGrid. The RadGrid code is shown below. Basically, the RadGrid below sets the CurrentFilterFunction property to default value, which is what we want. The issue is if a user changes the default filter function on multiple columns and attempts to filter based on those columns, it doesn't work because the first column filter that was changed will reset to the default CurrentFilterFunction value when the page posts back. Is there a way to save both filter function changes and allow the user to filter on multiple columns that way?
<telerik:RadGrid ID="TasksGrid" runat="server" >
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="TaskID" HeaderStyle-Width="95" ItemStyle-Width="95"    HeaderText="Task ID" SortExpression="TaskID" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <GridRadComboFilter:GridRadComboFilter DataField="FlagID" HeaderText="Flag" SortExpression="FlagID" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="50" />
            <telerik:GridBoundColumn DataField="AssignedTo" HeaderText="Assigned To" SortExpression="AssignedTo" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Site" HeaderText="Site" SortExpression="Site" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Product" HeaderText="Product" SortExpression="Product" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn >
            <telerik:GridBoundColumn DataField="SupportType" HeaderText="Support Type" SortExpression="SupportType" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"></telerik:GridBoundColumn >
            <telerik:GridBoundColumn DataField="Issue" HeaderText="Reported Issue" SortExpression="Issue" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn >
            <telerik:GridBoundColumn DataField="LastUpdatedText" HeaderText="Last Updated Text" SortExpression="LastUpdatedText" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn >
            <telerik:GridDateTimeColumn FilterControlWidth="110px" DataField="LastUpdatedDate" SortExpression="LastUpdatedDate" HeaderText="Last Updated Date" PickerType="DatePicker" DataFormatString="{0:d}" DataType="System.DateTime"></telerik:GridDateTimeColumn>
            <telerik:GridDateTimeColumn FilterControlWidth="110px" DataField="RequestedCompletionDate" SortExpression="RequestedCompletionDate" HeaderText="Req Completion Date" PickerType="DatePicker" DataFormatString="{0:d}" DataType="System.DateTime"></telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn >                   
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
Eyup
Telerik team
 answered on 06 Aug 2015
3 answers
265 views
Hi,

I have a simple RadGrid control.
For each data item in the Datasource I create a User Control.
The user control is determined at runtime according to the data-item (or data item id).
I use LoadControl function to load the control.

I want to add this control as a nested view template, so I can collapse/expand each row and edit the different controls.
Once I finish editing the controls - (all in client side), I hit a save button to persist all the information to database.

I will have to loop through the rows, get the user-control and execute a save function in it.

What would be the best practice to achieve this?
I started by adding NestedViewTemplate  with a container panel to hold the various user controls.
This is how it looks like:
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Id"  GroupLoadMode="Client" HierarchyLoadMode="Client">
                <NestedViewTemplate>
                    <asp:Panel runat="server" ID="configControlContainer" CssClass="viewWrap" Visible="true">
                    </asp:Panel>
                </NestedViewTemplate>
                <Columns>
.
.
.

Thank you,

-Itye
Eyup
Telerik team
 answered on 06 Aug 2015
6 answers
258 views
Hi guys,

I found this excellent example

http://demos.telerik.com/aspnet-ajax/scheduler/examples/outlook2007/defaultcs.aspx

Which is just what I need to implement.

But when I copy and paste into my application I get this error

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.


and stack trace

[HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]
   System.Web.UI.ControlCollection.Add(Control child) +11274544
   Telerik.Web.SkinRegistrar.RegisterCssReference(Page _page, Control _control, String _url) +619

[HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.]
   Telerik.Web.SkinRegistrar.RegisterCssReference(Page _page, Control _control, String _url) +724
   Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl _control) +1182


Do you have any clue, what I'm doing wrong?

Many thanks!
Maria Ilieva
Telerik team
 answered on 06 Aug 2015
1 answer
1.7K+ views

 I Added the grid in the Sharepoint web part  , I did not add any code behind  , I just added to the aspx the following : 

<telerik:RadGrid ID="RadGrid1" runat="server" >
 
</telerik:RadGrid>

The exception is:

 The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

 

  • [HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.] System.Web.UI.ControlCollection.Add(Control child) +353 Telerik.Web.SkinRegistrar.RegisterCssReference(Page page, Type registerType, String url) +618 [HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.] Telerik.Web.SkinRegistrar.RegisterCssReference(Page page, Type registerType, String url) +729 Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl control) +683 Telerik.Web.UI.RadGrid.ControlPreRender() +56 System.Web.UI.Control.PreRenderRecursiveInternal() +155 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4106

 

 

Any suggestions ?

Maria Ilieva
Telerik team
 answered on 06 Aug 2015
5 answers
78 views
Probably not possible but....

It would be neat if one could embed user controls into the editor. This would then allow us as developers to create editable layouts that contain user controls.

Thanks
Ianko
Telerik team
 answered on 06 Aug 2015
4 answers
109 views

We recently upgraded to .Net 4.5 and I am now receiving a 404 File or Directory Not Found error when I try to upload a pdf.  I have made all the changes to the web.config that were suggested in the documentation.

Any help would be appreciated

 

Ianko
Telerik team
 answered on 06 Aug 2015
2 answers
78 views

I have an issue with ​radgrids on public pages on my site (pages I want search engines to spider) are showing the back/next image button instead of the new "Mobile" buttons.

See attached images. One is from a datagrid with SEOPaging turn on (Old Buttons) and one with SEOPaging turned off (New Buttons).

Cradz
Top achievements
Rank 1
 answered on 05 Aug 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?