Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carson Brown 15 posts 85 karma points
    May 31, 2016 @ 19:58
    Carson Brown
    0

    Using Controllers and Models for Forms

    Hello,

    I am new to Umbraco and have been working on my first project. I really like Umbraco so far, but I have hit a snag in trying to create a form. All the articles I read explaining how to create a form say to create a model and a controller.

    This is my model and it is in a folder I created called Models

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    
    namespace UmbracoTrial.Models
    {
    public class QuoteViewModel
    {
        [Required]
        public string Name { get; set; }
    
        public string Company { get; set; }
    
        [Phone(ErrorMessage = "The phone number is invalid")]
        [Required]
        public string Phone { get; set; }
    
        [Required]
        [EmailAddress(ErrorMessage = "Email has to be a valid email address.")]
        public string Email { get; set; }
    
        public string Address { get; set; }
    
        [Required]
        public string City { get; set; }
    
        [Required]
        public string State { get; set; }
    
        [Required]
        [StringLength(10, MinimumLength = 5, ErrorMessage = "Zip code must be at least 5 numbers")]
        public string Zip { get; set; }
    
        public virtual ICollection<String> type_of_project { get; set; }
        public string Date { get; set; }
        public string Description { get; set; }
    }
    }
    

    There are no errors in this, but when I made a controllers folder and created a controller, I get an error saying that the namespace Models does not exist in my project. Anyone know what's going on here?

  • Paul Seal 524 posts 2890 karma points MVP 7x c-trib
    May 31, 2016 @ 20:12
    Paul Seal
    0

    Hi Carson

    Make sure you add the using statement at the top of the controller class

    using UmbracoTrial.Models;
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies