0

I have to call the method in the controller from view, but not using any click, so I am thinking to do it using the following line of code:

@Html.RenderAction("Replies", new { id= item.ID})  

and my method in the controller is like this:

public post Replies(int Id)  
    {  
        post posts = new post();  
        posts = new Data_Access().Get_Replies(Id);   
        return posts;  
    }  

but this is showing error saying that "can not implicitly convert type void to object"
can any one please help me.. thanks

Salomon Zhang
  • 1,553
  • 3
  • 23
  • 41
vijay yaragall
  • 111
  • 2
  • 12
  • You should use ajax. Visit this site. it will help you. http://stackoverflow.com/questions/5410055/using-ajax-beginform-with-asp-net-mvc-3-razor – Müslüm ÖZTÜRK Jun 11 '12 at 12:12

1 Answers1

1

RenderAction writes the result directly to the page and returns void.
@whatever writes the result of whatever to the page.

Since RenderAction doesn't return anything, it cannot be used in an @ block.

Instead, you should write @Html.Action(...).
Html.Action returns the result as an HelperResult object.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964