locked
class seen as type when using as model for razor page RRS feed

  • Question

  • User-1232255770 posted

    namespace InternalTools.CloudAd.Shared { public class Account { [Required] [DisplayName("First name")] public string FirstName { get; set; } [Required] [DisplayName("Last name")] public string LastName { get; set; } //[NotMapped] public string FullLDapName { get; set; } [Required] [DisplayName("Email address")] public string EmailAddress { get; set; } //[NotMapped] public string Password { get; set; } //public string Company { get; set; } //[NotMapped] public string UserPrincipalName { get; set; } // public int CompanyID { get; set; } //[NotMapped] public string AdGroupSelected { get; set; } //[NotMapped] public string AdOrgUnitSelected { get; set; } [Required] [DisplayName("Course type")] public string CourseType { get; set; } } }

    razor page

    @using InternalTools.CloudAd.Shared;
    @page "/cloudad"
    
    
    <EditForm Model="@Account" OnValidSubmit="@HandleValidSubmit">
        <DataAnnotationsValidator />
        <ValidationSummary />
    
        <InputText id="FirstName" @bind-Value="Account.FirstName" />
    
        <button type="submit">Create Account</button>
    </EditForm>
    
    @code {
        private Account account = new Account();
    
        private void HandleValidSubmit()
        {   
    }
    }
    

    Model="@Account"  , gives the following error

    CS0119 C# 'Account' is a type, which is not valid in the given context

    Any ideas ?

    Tuesday, September 22, 2020 12:29 PM

Answers

  • User-1232255770 posted

    Should be  Model="@account" , typo.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 22, 2020 1:52 PM