2012-01-15 53 views
1

我已经是asp.net mvc 2 WebSite。 有一个页面:将param传递给RenderPartial

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

我的局部视图(我所有的局部视图包括静态的HTML数据):

<%@ 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> 

和控制器:

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

     } 

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

我想知道,当用户点击列表项目,该项目必须作为RenderPartial的参数传递。这个怎么做?

回答

0

编译页面时会执行Html.RenderPartial方法。这发生在服务器上。你要求的是客户端的html操作。您可以通过对actionresult方法使用ajax调用来处理此操作,该方法返回可以指向文章div的部分页面。这可能帮助:

Walkthrough: Adding AJAX Call

0

您可以使用Ajax dynamicaly内<div class="article">更新内容。欲了解更多有关如何加载局部视图使用Ajax看看这些资源:

相关问题