[RESOLVED]How to get values in another page when submit button is clicked

Hi

i am having following page.i want to get "var1","var2" in another page(posted page)

Please help me

@using (Html.BeginForm("InsertPayroll","Home",FormMethod.Post))
{

<table>
<tr>
<td>Department:
</td>
<td>
@Html.DropDownList("var1", "Choose Department")

</td>
</tr>
<tr>
<td>Employee:
</td>
<td>
@Html.DropDownList("var2", "Choose Employee")
</td>
</tr>

<tr>
<td>@Html.Label("Job Type")</td>
<td>
@Html.DropDownList("JobType")
</td>
</tr>

<tr>
<td>@Html.Label("Salary")</td>
<td>
@Html.TextBox("Salary")
</td>
</tr>
<tr>
<td>

<input id="Submit1" type="submit" value="submit" />

</td>

</tr>
</table>
}

In model I got

public class Payrolldata
{

public int empid { get; set; }

public int deptid { get; set; }

public int jobtype { get; set; }

public string empname { get; set; }

public string deptname { get; set; }

public string jobtypename { get; set; }

public int Salary { get; set; }

public DataSet StoreAllData { get; set; }
}

Thanks

Chandran

In your controller you would have

// Below gets the page when its first requested, you pass in the model to the view
[HttpGet]
public ActionResult Page(){

var model = new Payrolldata();

return view(model);

}


// Next same as the above but its a [HttpPost] when the submit button is pressed it will call the below

[HttpPost]
public ActionResult Page(Payrolldata model){


// Do what ever you need with the model, Business Logic, Saving data

return RedirectToAction(ActionName, ControllerName);


}

If unclear post your controller

Hi rchandran.nr,

Thanks for your post.

According to your description,

rchandran.nr

How to get values in another page when submit button is clicked

Please refer to the following link:

http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply