1

I've asp.net mvc 2 WebSite. There is one page as:

   <div id="sidebar">
        <div id="navcontainer">
            <h2>
                Items:</h2>
            <ul id="navlist">
                <li id="active"><a href="#" id="current">item1</a></li>
                <li><a href="#">item2</a></li>
                <li><a href="#">item3</a></li>
                <li><a href="#">Item four</a></li>
                <li><a href="#">Item five</a></li>
            </ul>
        </div>
    </div>
    <div class="article">
        <%Html.RenderPartial("item1");%>
    </div>

My Partial View(all my partial views include static html data):

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>


<h1>
    Lorem</h1>
<p>
    In publishing and graphic design, lorem ipsum[p][1] is placeholder text (filler text) commonly used to demonstrate the graphics elements of a document or visual presentation, such as font, typography, and layout. The lorem ipsum text is typically a section of a Latin text by Cicero with words altered, added and removed that make it nonsensical in meaning and not proper Latin.
</p>

And Controller:

public class InfoController:Controller
{
        private DataManager _dataManager;
        public RegionsController(DataManager dataManager)
        {
            this._dataManager = dataManager;

        }

        public ActionResult info()
        {
            return View(); ;
        }
}

I want realize, when user clicks on list items, this item must passed as parameter of RenderPartial. How to do this?

loviji
  • 12,620
  • 17
  • 63
  • 94

2 Answers2

0

The Html.RenderPartial method is executed when the page is compiled. This happens at the sever. What you are asking for is an html action at the client side. You can handle this by using an ajax call to a actionresult method that returns a partial page to which you can point to your article div. This might help:

Walkthrough: Adding AJAX Call

James Santiago
  • 2,883
  • 4
  • 22
  • 29
0

You can use Ajax to dynamicaly update content inside <div class="article">. For more on how to load partial views with ajax check out these resources:

Community
  • 1
  • 1
Emmanuel N
  • 7,350
  • 2
  • 26
  • 36