0

I have a form that I save three entites in this form.

public class NewAccountWrapperModel
{
    Person Student = new Person();
    Person Parent = new Person();
    Reports Reports = new Reports();

    public NewAccountWrapperModel(Person student, Person parent, Reports reports)
    {
        this.Student = student;
        this.Parent = parent;
        this.Reports = reports;
    }
}

I prepare a model like above. In my html page, I uses it like below:

@model RAM_Web.Models.NewAccountWrapperModel
<!DOCTYPE html>



<span class="field">
   <input type="text" name="firstname" id="firstname2" class="longinput" />
   @Html.TextBoxFor(d=>d.Student.Name)
</span>

I try to achive to Student model using d.Student.Name. But it gives error.

 NewAccountWrapperModel' does not contain a definition for 'Student' and no extension   method 'Student'

like this. In Person model, there is Name field. I controlled it.

1 Answer 1

1

Change from:

Person Student = new Person();
Person Parent = new Person();
Reports Reports = new Reports();

to:

public Person Student { get; set; }
public Person Parent { get; set; }
public Reports Reports { get; set; }
Sign up to request clarification or add additional context in comments.

1 Comment

thanks so muck. it is my carelessness. I don't notive that.Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.