Home How to add a value to a class if the class contains LIST<class>
Reply: 0

How to add a value to a class if the class contains LIST<class>

user6916 Published in September 20, 2018, 1:06 pm

I have a class graf.

public class Graf
        public List<Point> first { get; set; }
        public List<Point> second { get; set; }

This class contains List

public class Point
        public int x { get; set; }
        public int y { get; set; }

        public Point(int x, int y)
            this.x = x;
            this.y = y;

I need to add a Point into class Graf from index.cshtml:

@model WebApplication2.Models.Graf
                <div class="item">
                    <input name="Y11" value="@Model.first" />  --------??
    <input type="submit" value="Send" />

But i dont now how i can input into Graf class Point?

How can I do it?

share|improve this question
  • You just need to pass your object from client to controller and than add this object to your list: first.Add(point) – Qwerty Qwerty Feb 11 at 11:13
  • Ok, i have method for add Point in controller, but how can i call this method from client? For example i have <input name = "Y11"> and how i must put class Point from index.csHtml. Thank you! – Kirill Zorin Feb 11 at 13:38

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.429098 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO