ktm
ktm

Reputation: 6085

Passing data from one page to another in razor webpage

I have a select form which refresh itself after slection 'category' to dispaly 'sub category' I did put validation in subcategory so that user goes to next page only after sub category

I have a code in page 1 like this

if (IsPost && Validation.IsValid())
{
    parent = Request.Form["parent"];
    Response.Redirect("~/Members/cb/Page2");
}

and in page 2

 @Html.Hidden("parent", Request.Form["parent"])

however , I cannot get hidden value in page2 that was passed from page 1, pls help

Upvotes: 1

Views: 1986

Answers (1)

petro.sidlovskyy
petro.sidlovskyy

Reputation: 5093

Try pass parent in url to second page:

Response.Redirect("~/Members/cb/Page2?parent=" + Request.Form["parent"]);

If you do redirect hidden filds will not be available on redirected page. Hidden fields as any other input are only posted back to server on form submit.

Upvotes: 1

Related Questions