I am very new in asp.net MVC kindly let me know where is should use partial view and where i should Render Partial view . Thanks in advance
            Asked
            
        
        
            Active
            
        
            Viewed 2.1k times
        
    2
            
            
        - 
                    3Possible duplicate of [Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction](http://stackoverflow.com/questions/5248183/html-partial-vs-html-renderpartial-html-action-vs-html-renderaction) – CodeNotFound Nov 01 '16 at 05:12
2 Answers
9
            
            
        Html.RenderPartial
- This method result will be directly written to the HTTP response stream means it used the same TextWriter object as used in the current webpage/template.
- This method returns void.
- Simple to use and no need to create any action.
- RenderPartial method is useful when the displaying data in the partial view is already in the corresponding view model.
- For example : In a blog to show comments of an article, we would like to use RenderPartial method since an article information with comments are already populated in the view model.
@{Html.RenderPartial("_Comments");}
- This method is faster than Partial method since its result is directly written to the response stream which makes it fast.
Html.Partial
- Renders the partial view as an HTML-encoded string.
- This method result can be stored in a variable, since it returns string type value.
- Simple to use and no need to create any action.
- Like RenderPartial method, Partial method is also useful when the displaying data in the partial view is already in the corresponding view model.
- For example: In a blog to show comments of an article, you can use Partial method since an article information with comments are already populated in the view model.
@Html.Partial("_Comments")
 
    
    
        Akshay Soam
        
- 1,580
- 3
- 21
- 39
0
            
            
        Both of these helper method are used for rendering partial views
Both have different syntax in razor view @Html.Partial("_student", items) and {Html.RenderPartial("_student", items);}, since render partial return void and the output is written directly to output stream, it has different syntax than Partial.
Syntax in web from view
<%:Html.Partial("_student") %> and <% Html.RenderPartial("_student"); %>
Partial Returns MVCHtmlString, which can be assigned to variables.
Performance wise Render partial is better as it writes directly to output stream.
And of-course you can find a lot of references online and within stack overflow to read
 
    
    
        James
        
- 729
- 6
- 10
