locked
Passing a variable in @RenderBody() RRS feed

  • Question

  • User-1753299103 posted

    Is this possible in the layout page:

     @RenderBody(myid)

    And then retrieving it via PageData[0]

    Thanks

    Saturday, May 9, 2015 11:49 AM

Answers

  • User1526116210 posted

    It's not possible to pass values through RenderBody(). Your best option is to use session variables or to use

    RenderPage("~/SomePage.cshtml", new { foo = "bar" }) 

    And then accessing that variable on SomePage.cshtml using

    string foo = Page.foo;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 10, 2015 4:48 AM