Stark
Stark

Reputation: 441

How to pass values between two pages using Razor in Webmatrix?

I am new to Razor and Webmatrix.I was trying to pass values using POST method from one page to another page but i am not able pass values. I have googled on it but didn't get any solutions. So can any one provide me the guidance?

Upvotes: 0

Views: 5159

Answers (2)

Yehia A.Salam
Yehia A.Salam

Reputation: 2078

A typical way to do it if both pages are in the same project:

  1. Post the form to a specific controller.
  2. Using the controller arguments, pass the data to the view model of the other page, and render the View

Upvotes: -1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038810

What are you having difficulties with? On one page you create a <form>:

<form action="/foo.cshtml" method="post">
    <input type="text" name="bar" value="" />
    <button type="submit">OK</button>
</form>

and on the other page you read values from the request: Request["bar"]:

@{
    var bar = Request["bar"];
}

Upvotes: 5

Related Questions