P
P
Paul Fawkes2019-06-19 04:19:28
ASP.NET
Paul Fawkes, 2019-06-19 04:19:28

How to display the result in POST controller?

PointX and PointY are not displayed in the view (probably because the result in the debugger is null in the controller) please help me fix
Created models

public int UserDataId
        {
            get;
            set;
        }

        [Required]
        public int RangeFrom
        {
            get;
            set;
        }

        [Required]
        public int RangeTo
        {
            get;
            set;
        }

        [Required]
        public float Step
        {
            get;
            set;
        }

        [Required]
        public int a
        {
            get;
            set;
        }

        [Required]
        public int b
        {
            get;
            set;
        }

        [Required]
        public int c
        {
            get;
            set;
        }

public int PointId
        {
            get;
            set;
        }

        public int ChartId
        {
            get;
            set;
        }

        public double PointX
        {
            get;
            set;
        }
        public double PointY
        {
            get;
            set;
        }

Created a view
<div>
    <form method="post" action="">
        <b>Function</b>
        y = <input type="number" name="a" />x^2 + <input type="number" name="b" />x + <input type="number" name="c" />
        <br />
        <br />
        <b>Step</b>
        <input type="number" name="Step" />
        <br />
        <br />
        <b>From</b>
        <input type="number" name="RangeFrom" />
        <b>To</b>
        <input type="number" name="RangeTo" />
        <br />
        <br />
        <br />
        <input type="submit" value="PLOT" />
    </form>
</div>

model List<WebApplication1.Models.PointModel>

<h1>Results</h1>

<ul>
@foreach(var item in Model)
{
   <li>@item.PointX</li>
   <li>@item.PointY</li>
}
</ul>

And the controller itself
[HttpGet]
        public ActionResult CountGet()
        {
            return View();
        }
        
        [ActionName("CountGet")]
        [HttpPost]
        public ActionResult ShowFunc(UserDataModel data)
        {
            var result = FuncLogic.Fx(data);
            return View(result);
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question