0

I have got asp.net mvc 3 website, I want to add feedback feature to all pages.

I created the partial view for this purpose and render it in master layout.

    @model FeedbackHelper
    Name:<br />
    @Html.TextBoxFor(o=>Model.Name)

for example in Questions page , MVC returns the exception because that page binded the POST entity, as far as I check in StackOverflow I have got 2 solution

  • create a parent model and add POST and FeedbackHelper as properties
  • use Tuple

at the moment, changing all models is too risky for me.

Is there any good solution ?!

Community
  • 1
  • 1
Mironline
  • 2,755
  • 7
  • 35
  • 61

1 Answers1

1

You could use child actions. The idea is to define a specific controller action that will serve the partial view and then include it using the @Html.Action helper in your Layout.

So:

public ActionResult Feedback()
{
    FeedbackHelper model = ...
    return PartialView(model);
}

then you will of course have a partial in the Shared folder:

@model FeedbackHelper
Name:<br />
@Html.TextBoxFor(o => o.Name)

and include it in your Layout:

@Html.Action("Feedback", "ControllerContainingTheFeedbackAction")
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928