0

I have the following structure:

  1. Site.Master

  2. Home - View

  3. HomeController - Controller

In the Site.Master I have a header that contains several ActionLinks, one of which is a Faq. In the Home view I have HTML that essentially displays static content, but, in the center pane/div I want to have dynamic content, based on certain HTML.ActionLinks that the user clicks on. So, for example, initially, I want the center DIV to display an intro - but if the user clicks on my Faq ActionLink, I want the center DIV to display content specific to my Faq.

In the HomeController I have the following:

[HttpGet]
    public ActionResult Intro()
    {
        var introRequest = _gatewayService.GetContent(new GetContentRequest { Content = ContentTypes.Introduction });

        ViewData["content"] = introRequest.Result;

        return View();
    }

 [HttpGet]
    public ActionResult Faq()
    {
        var faqRequest = _gatewayService.GetContent(new GetContentRequest { Content = ContentTypes.Faq });

        ViewData["content"] = faqRequest.Result;

        return View();
    }

The idea would be that the action link for Faq would look something like:

<%= Html.ActionLink("Faq","Faq","Home") %> 
0

2 Answers 2

1

As @Valamas said, use Ajax.ActionLink. For example,
In markup:

<div id=”faqContent”>
   @Ajax.ActionLink(“Click here to see FAQ!”,
      “Faq”,
      new AjaxOptions{
         UpdateTargetId=”faqContent”,
         InsertionMode=InsertionMode.Replace,
         HttpMethod=”GET”
      })
</div>

And in controller:

public ActionResult Faq()
{
    var faqRequest = _gatewayService.GetContent(new GetContentRequest { Content = ContentTypes.Faq });

    return PartialView("Faq", faqRequest.Result);
}

And finally have a partial view Faq.chtml with required html for FAQ.

Sign up to request clarification or add additional context in comments.

Comments

0

First you will need to change the result of your action methods in your controller,instead of actionresult you can use jsonresult Second, in the view you can use jquery to load the dynamic content

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.