Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:23:51+00:00 2026-06-18T10:23:51+00:00

How to access posted form data in action method and display in view I’m

  • 0

How to access posted form data in action method and display in view

I’m creating an input wizard in MVC. There are two views, one for taking input from user and another for display the input data.

Here is the model’s code:

 public class Info
  {
    public int CustomerId { set; get; }
    public double Price { set; get; }
    public string name { set; get; }
  }
}

Controller’s Code-

    public ActionResult FillCustomer()
    {
        return View();
    }

    public ActionResult DisplayCustomer(FormCollection frm)
    {
        Info info = new Info();

        info.name = Convert.ToString( Request.Form["name"]);
        info.Price = Convert.ToDouble(Request.Form["price"]);
        info.CustomerId = Convert.ToInt32(Request.Form["customerid"]);

        return View(info);
    }

FillCustomer View’s Code-

<form method="post" action="DisplayCustomer">
Name: <input type="text" id="name" /><br />
Price: <input type="text" id="price" /><br />
CustomerId: <input type="text" id="customerid" />
<br />
<input type="submit" id="btn1" />
</form>
</body>
</html>

DisplayCustomer View’s Code-

<body>
<div>
Name is <%=Model.name %> and ID is <%=Model.CustomerId %>

<%if (Model.Price > 200)
  {%>

Greater than 200

<%}
  else %>

<%{%>Lesser than 200 

    <%} %>
    </div>
</body>
</html>

I checked with debugger, controller is not getting posted data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:23:52+00:00Added an answer on June 18, 2026 at 10:23 am

    Your form’s input elements should have a name attribute

    <form method="post" action="DisplayCustomer">
    Name: <input type="text" id="name" name="name" /><br />
    Price: <input type="text" id="price" name="price" /><br />
    CustomerId: <input type="text" id="customerid" name="customerid" />
    <br />
    <input type="submit" id="btn1" />
    </form>
    

    Now you will get form data as

            Info info = new Info();
            info.name = Convert.ToString( Request.Form["name"]);
            info.Price = Convert.ToDouble(Request.Form["price"]);
            info.CustomerId = Convert.ToInt32(Request.Form["customerid"]);
    

    In controller, form data is received as key/value pairs. And keys are generaetd from name attributes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CodeIgniter allows access to POSTed data via: $this->input->post('input_name'); where 'input_name' is the name of
I want to fetch posted data. But I am using no form. The data
I am trying to post data to MVC controller action but have been unsuccessful
Is there a way to access the database object from the django form cleaner?
If data is submitted via POST through the classic HTML form method is it
I have a form and when its posted, some of its data gets saved
I've posted a demo Access db at http://www.derekbeck.com/Database0.accdb . I'm using Access 2007. I
Any Access guru's out there that can help me out? Trying to figure out
Which access modifiers which when used with the method makes it available to all
I'm having problems accessing the posted values after a form submission with Drupal 7.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.