Copied to clipboard

Flag this post as spam?

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


  • Robertpurpose 1 post 21 karma points
    Sep 06, 2013 @ 23:12
    Robertpurpose
    0

    Error loading Partial View script

    I am new to the MVC in Umbraco and have been playing with things a little at a time. I finally got the look to work and I am working on the functionality. I created the model in the same folder at the DbContext, Controllers on its on and Have a Views folder which has Macro Partial Folder and the actual view in it. Along with all of this my validation does not work. Now when then user hits submit I get this error: Error loading Partial View script (file: ~/Views/MacroPartials/ApplicationFormStub.cshtml)

    Here is what I have for each file

    Model:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.ComponentModel;

    using System.ComponentModel.DataAnnotations;

     

    namespace Umbraco..CareerServices

    {

    [MetadataType(typeof(ApplicationMetaData))]

        public partial class Application { }

        public class ApplicationMetaData

        {

            [DisplayName("Employer Name")]

            [Required (ErrorMessage="Please Enter the Employer's Name")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string EmployerName { get; set; }

     

            [DisplayName("Supervisor Name")]

            [Required (ErrorMessage="Please Enter the Supervisor's Name")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string SupervisorName { get; set; }

     

            [DisplayName("Supervisor Title")]

            [Required (ErrorMessage="Please Enter the Supervisor's Title")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string SupervisorTitle { get; set; }

     

            [DisplayName("Employer Address")]

            [Required (ErrorMessage="Please Enter the Employer's Address")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string EmployerAddress { get; set; }

     

            [DisplayName("Employer City")]

            [Required (ErrorMessage="Please Enter the Employer's City")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string EmployerCity { get; set; }

     

            [DisplayName("Employer State")]

            [Required (ErrorMessage="Please Enter the Employer's State")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public object EmployerState { get; set; }

     

            [DisplayName("Employer Zip")]

            [Required (ErrorMessage="Please Enter the Employer's Zip")]

            [StringLength(50, ErrorMessage = "Only 50 Characters allowed")]

            public string EmployerZip { get; set; }

     

            [DisplayName("Employer Phone")]

            [StringLength(10, ErrorMessage = "Only 10 Characters allowed")]

            public string EmployerPhone { get; set; }

        }    

    }

    Controller

     [HttpGet]

            [ActionName("ShowApplication")]

            public ActionResult ShowApplication()

            {    

                return PartialView("CareerServicesApplicationForm", new ApplicationMetaData());

            }

     

            [HttpPost]

            [ValidateAntiForgeryToken]

            [ActionName("ShowInternshipApplication")]

            public ActionResult ShowApplication(ApplicationMetaData Model)

                {

                 if (ModelState.IsValid)

                    {

                    try

                        {

                            CreateEntryIA(Model);

                        }

                    catch (Exception oe)

                        {

                            Response.Write(oe.Message);

                             Response.End();

                        }

     

                    //Send Email 

                    return RedirectToAction(RedirectUrl);

                    }

     

                return PartialView("ApplicationForm", new ApplicationMetaData());

                }

    Macro Partial:

    @Html.Action("ShowApplication", "ServicesSurface")

    View:

    @using Umbraco.Web

    @using UmbracoProd.code

    @model UmbracoProd.Services.ApplicationMetaData

     <link href="@Url.Content("/../../css/Services/form.css")" rel="stylesheet" type="text/css" />

        @using (Html.BeginUmbracoForm("showApplication", "ServicesSurfaceController"))

        {

            @Html.AntiForgeryToken()

            @Html.ValidationSummary(true)

     

    <div class="FormArea">

            <fieldset>

                <legend>Section One</legend>

                <ul>

                    <li>

                        @Html.LabelFor(x => x.EmployerName)

                        @Html.TextBoxFor(x => x.EmployerName)

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.EmployerName)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.SupervisorName)

                        @Html.TextBoxFor(x => x.SupervisorName)

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.SupervisorName)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.SupervisorTitle)

                        @Html.TextBoxFor(x => x.SupervisorTitle)

                    </li>

                     <li>

                        @Html.ValidationMessageFor(x => x.SupervisorTitle)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.EmployerAddress)

                        @Html.TextBoxFor(x => x.EmployerAddress)

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.EmployerAddress)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.EmployerCity)

                        @Html.TextBoxFor(x => x.EmployerCity)

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.EmployerCity)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.EmployerState)                    

                        @Html.StateDropDownList("EmployerState", "IN")

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.EmployerState)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.EmployerZip)

                        @Html.TextBoxFor(x => x.EmployerZip)

                    </li>

                    <li>

                        @Html.ValidationMessageFor(x => x.EmployerZip)

                    </li>

                    <li>

                        @Html.LabelFor(x => x.EmployerPhone)

                        @Html.TextBoxFor(x => x.EmployerPhone)

                    </li>

            </fieldset>        

         <input type="submit" class="button" value="Submit"/>

      </div> 

        }

    Could anyone give me some advice on how to work my way through this?

  • 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