0

So I have read this question (Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction) and understand what Html.Partial and Html.Action do.

But I am trying to understand why these were introduced. Could you please explain a scenario where I would want to get back a MvcHtmlString instead of writing it out to the response stream? I am sure there is a big use case for this.

Thanks!

Community
  • 1
  • 1
rkrauter
  • 1,159
  • 1
  • 11
  • 23
  • @Andrews Barber 's answer was correct and I was reading the question differently than he was. I'm not sure why he deleted it. – John Farrell Apr 15 '11 at 04:20

1 Answers1

1

Having MvcHtmlString gives you more flexibility. You may modify it before using or store it to avoid complex rerendering.

Alexander Prokofyev
  • 33,874
  • 33
  • 95
  • 118
  • 1
    Exactly. Also, it allows a nicer syntax when calling it from Razor. You can do this: @Html.Partial(...) rather than @{Html.RenderPartial(...);} – Haacked Apr 18 '11 at 04:26