xnr_z
xnr_z

Reputation: 1201

C# MVC - How can I pass some method arguments as parameters inside a Controller?

I have a controller action like this:

public ActionResult Test(string par)
{
    Model myMod = new Model();
    myMod.Attribute = par;
    return View(myMod);
}

In the Test View I'd like to retrieve and print that attribute...
like this:

@model Project.Models.Model

@Html.DisplayFor(model => model.Attribute)

But by doing in that way I'm not able to retrieve the data from the action.

Upvotes: 0

Views: 140

Answers (1)

Andy T
Andy T

Reputation: 9901

In your model, the property is called, Attribute, but in the view, you are referencing Attrubute:

@Html.DisplayFor(model => model.Attribute)

Upvotes: 2

Related Questions