Solved

MVC & Bootstrap Accordion

Posted on 2013-06-25
2
1,325 Views
Last Modified: 2013-06-27
Hi:

I'm trying to create a data-based FAQ in MVC4 using EntityFramework and Bootstrap.  

The following code works with 2 problems:

<div class="accordion" id="accordion2">
            <div class="accordion-group">
                 @foreach (var item in Model.Faqs)
                 {
                     <div class="accordion-heading">
                         <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">@Html.DisplayFor(modelItem => item.Question)
                         </a>
                     </div>
                     <div id="collapseOne" class="accordion-body collapse ">
                         <div class="accordion-inner">
                             @Html.DisplayFor(modelItem => item.Answer)
                         </div>
                     </div>
                 }
            </div>

        </div>

Open in new window


The problems are:

1.  The same answer opens for all questions.  I am not sure how to dynamically refer to each question's answer;

2.  The answer comes from a sql server field of raw Html.  When I try to use Html.Raw instead of Html.DisplayFor, I get the error that "Cannot resolve the method 'Raw(lamda expression)

Any help in completing this greatly appreciated.

RBS
0
Comment
Question by:RBS
2 Comments
 
LVL 23

Accepted Solution

by:
Roopesh Reddy earned 500 total points
ID: 39282111
Hi,

You may have to use jQuery selectors to dynamically select!

Regarding Html.Raw(), do you have the model type as String?

http://msdn.microsoft.com/en-us/library/gg480740(v=vs.98).aspx

Can you try like this -

@Html.Raw(item.Answer)

Open in new window


Hope it helps u...
0
 

Author Closing Comment

by:RBS
ID: 39282187
thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Store results in vb.net 3 24
VB.NET 2008 Publish Error 2 33
location of a form 2 25
Input parameteres to DragOver 2 19
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question